> 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):
Whi
Alan Gauld wrote:
>> But you normally shouldn't call this directly, you should write
>> "test" in menu_specials
>
>
> Now howzabout that! Yet another new trick learnt.
> When did 'in' start working with dictionaries?
Oh, about four years ago :-) in Python 2.2
You really should read the "What's
> But you normally shouldn't call this directly, you should write
> "test" in menu_specials
Now howzabout that! Yet another new trick learnt.
When did 'in' start working with dictionaries?
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.p