Way for see if dict has a key

Fredrik Lundh fredrik at pythonware.com
Fri Jun 30 07:36:29 EDT 2006


Michele Petrazzo wrote:

>> Michele Petrazzo wrote:
>>
>>>>> key in dict
>>>> new syntax (2.3 and later).
>>> So, following it, it can be used for the operations like len?
>>
>> what's "it" in this sentence?
>
> It, is the thought that the new 2.3 introduce.

support for "key in dictionary" form was added in 2.3 (in earlier versions,
"in" was only supported for sequences, not for mappings).

len(dictionary) works in all Python versions.

</F> 






More information about the Python-list mailing list