Thanks, that helped. I took a second look and realized where I had tried calling the .strip() method was wrong. Appreciate the pointer.
Becky On Thu, Mar 3, 2011 at 5:37 PM, Kushal Kumaran < kushal.kumaran+pyt...@gmail.com> wrote: > On Fri, Mar 4, 2011 at 6:48 AM, Becky Mcquilling <ladymcse2...@gmail.com> > wrote: > > I am creating a dictionary by parsing a text file. > > > > The code is below: > > backup_servers = {} > > fo = open('c:/test/backup_shares.txt') > > for line in fo: > > backup_server = line.split(',') > > backup_servers[backup_server[0]]=backup_server[1] > > Looping over a file object returns lines including the trailing > newline. If that's not required, you have to remove the newline at > the end yourself using the strip method. > > To see the behaviour, print out the value of line at the start of the loop > body. > > Documentation on file objects: > http://docs.python.org/library/stdtypes.html#file-objects > Documentation on strings: > http://docs.python.org/library/stdtypes.html#string-methods > > > <snip> > > -- > regards, > kushal >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor