[Tutor] For loop question
STREET Gideon (SPARQ)
Gideon.STREET at ergon.com.au
Thu May 11 06:51:01 CEST 2006
I'm running version 2.4.2
Just set up another test file and it's working with:
HostFile = open("hosts.txt", 'r')
for item in (x.strip() for x in HostFile):
print "Connecting to device",item
..telnet and do other stuff here...
I must have typed something incorrectly previously :\
Thanks again
Gideon (aka Fatfingers)
-----Original Message-----
From: w chun [mailto:wescpy at gmail.com]
Sent: Thursday, 11 May 2006 1:11 PM
To: STREET Gideon (SPARQ)
Cc: tutor at python.org
Subject: Re: [Tutor] For loop question
> Thanks all, appears it is the newline character which was causing me
> grief. For some reason I still have to do a readlines on the open
> file at this stage, but I can muck about with that to figure it out.
that is surprising... i would be interested in hearing what problems you
are encountering while iterating through a file. if you have any output
or problem description to share with us, that would be great.
what version of Python are you running?
cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python
Programming", Prentice Hall, (c)2007,2001
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting cyberweb.consulting : silicon
valley, ca http://cyberwebconsulting.com
This e-mail (including any attachments) may contain confidential or
privileged information and is intended for the sole use of the person(s) to
whom it is addressed. If you are not the intended recipient, or the person
responsible for delivering this message to the intended recipient, please
notify the sender of the message or send an e-mail to
mailto:help.desk at ergon.com.au immediately, and delete all copies. Any
unauthorised review, use, alteration, disclosure or distribution of this
e-mail by an unintended recipient is prohibited. Ergon Energy accepts no
responsibility for the content of any e-mail sent by an employee which is of
a personal nature.
Ergon Energy Corporation Limited ABN 50 087 646 062
Ergon Energy Pty Ltd ABN 66 078 875 902
More information about the Tutor
mailing list