problem with special built-in method __contains__,

Paul Hankin paul.hankin at gmail.com
Tue Oct 2 07:34:25 EDT 2007


On Oct 2, 12:14 pm, "ebo... at gmail.com" <ebo... at gmail.com> wrote:
> if i have a dictionary  name number ....and i want to    ask the list
> whether a particular key already
> exists.
>
> >>> print number
>
> {'octal': '1234567', 'binary': '10100101', 'decimal': '1234567890',
> 'hexadecimal': '1-9,a-f'}
>
>  i got  error..after execute
>
>  >>>number._contains_("test")

It's __contains__ and not _contains_. But better is just:
  'test' in number

--
Paul Hankin




More information about the Python-list mailing list