Problem with loading textfiles into dictionaries.
steven.bethard at gmail.com
Mon Jan 31 01:25:17 EST 2005
> mercuryprey at gmail.com said the following on 1/30/2005 7:43 PM:
>> I want to do the following:
>> def do_load(self, arg):
>> sitefile = file('sitelist', 'r+', 1)
>> while True:
>> siteline = sitefile.readline()
>> site_rawlist = siteline.split()
>> sitelist[site_rawlist] = site_rawlist[1:]
>> if len(siteline) == 0:
> You should move "if len(siteline) == 0" part right after your readline.
> The way you have done it really does not help.
Or better yet, don't use "if len(siteline) == 0" -- use "if siteline".
See this an other examples of dubious Python:
Specifically, see the section on Overly Verbose Conditionals.
More information about the Python-list