Hi Joseph, I'm unable to cc to the Python list from this address, so I'll try my forwarding address.
>Example: >this >is >the >type >of >message >I'm >getting >and >as >you >can >see >, >it's >really >annoying! You know that 'print' adds a newline? You could either use - import sys sys.stdout.write(msg[print_msg]) or, to simplify things - I would recommend either - space = ' ' for item in msg: item.rstrip() joinedMsg = space.join(msg) or nullString = '' joinedMsg = nullString.join(msg) noNewlinesMsg = joinedMsg.replace('\n', nullString) Let me know how it goes. Regards, Liam Clarke-Hutchinson ________________________________________ From: Joseph Quigley [mailto:[EMAIL PROTECTED] Sent: Tuesday, 20 September 2005 2:19 a.m. To: Liam Clarke-Hutchinson; tutor@python.org Subject: Re: [Tutor] IRC Client Trouble -- too many new lines Hi, Liam Clarke-Hutchinson wrote: Hi Joseph, while (1): buffer = Data.IRC.recv(1024) msg = string.split(buffer) Just a warning, the string module will be removed/deprecated come Py3K. Better to use - buffer.split() nick_name = msg[0][:msg[0].find("!")] filetxt.write(nick_name.lstrip(':') + ' -> ' + message.lstrip(':') + '\n') Ok. Thanks for the heads up. As to your printing problem, I'm not sure if you're referring to - print msg[print_msg] Oh, sorry. I'm refering to the print msg[print_msg] And I'm not sure if you want it to print without an additional newline, or with a newline. Well every word is on it's own new line (I get a huge message from the IRC server) and I'd like a word wrap or something to fix that. #Incidentally, it's a bit simpler to maintain this kinda loop #instead of a while loop. for item in msg: item.rstrip() #Will strip whitespace (\t\r\n etc.) by default print item Ah. Thanks If you're wanting to print without the newline that print adds, why not do a join like this one? message = ' '.join(msg[3:]) print ' '.join(msg) ? Thanks again. This is proving very usefull. What output you're expecting I'm expecting a large amount of text without new lines for each word, and possible word wrapping. What output you're getting Example: this is the type of message I'm getting and as you can see , it's really annoying! PS Your code is interesting, I've never dealt with the IRC protocol before,so it's good to see a demonstration of it. I edited the code from a Python Cookbook recipe. I may toddle off and check out that RFC. Yes. Some people on a forum that I hang oput with suggested a chat room. A freind of mine suggested IRC and python. He's doing the server and I'm doing the client. I'm testing the client on freenode.. only thing I could think of at the time. A new monthly electronic newsletter covering all aspects of MED's work is now available. Subscribers can choose to receive news from any or all of seven categories, free of charge: Growth and Innovation, Strategic Directions, Energy and Resources, Business News, ICT, Consumer Issues and Tourism. See http://news.business.govt.nz for more details. http://www.govt.nz - connecting you to New Zealand central & local government services Any opinions expressed in this message are not necessarily those of the Ministry of Economic Development. This message and any files transmitted with it are confidential and solely for the use of the intended recipient. If you are not the intended recipient or the person responsible for delivery to the intended recipient, be advised that you have received this message in error and that any use is strictly prohibited. Please contact the sender and delete the message and any attachment from your computer. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor