My Big Dict.

Aurélien Géron ageron at HOHOHOHOvideotron.ca
Wed Jul 2 14:49:38 EDT 2003


> [...snippage...]
>
> d={}
> for l in file("test.txt"):
>     try: i=l.index('!')
>     except ValueError: continue
>     d[l[:i]]=l[i+1:]
>
> [...snippage...]

Just a little note : I generally try to avoid lowercase L and uppercase i as
variable names, because in many fonts, there's barely any difference
(sometimes none at all) between l and 1 and I  (resp. lowercase L, number 1
and capital i).

For example : would you be able to find out what the result of the following
code is just by looking at it?  If you think you can, run it through python
and see if you were right!

l=1l
I=1+l
print l+l*I

Cya,
Aurélien






More information about the Python-list mailing list