> I used to want that syntax when I started, now I stick to for x in 
> y.keys()

I knew you could do

for item in dictionary:

instead of

for item in dictionary.keys():

But I didn't realise it worked for a single item test too

if item in dictionary

instead of

if dictionary.has_key(item):

While the loop is probably as easy to read either way
the test is much cleaner using 'in'.

Nice.

Alan g.

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to