Specifing arguments type for a function

George Sakkis george.sakkis at gmail.com
Fri Jun 23 01:48:47 CEST 2006


Bruno Desthuilliers wrote:

> George Sakkis a écrit :
> > This is ok - in theory. In practice I've found that e.g. strings are
> > more often than not handled as scalars although they are typically
> > iterables.
>  >>> hasattr('', '__iter__')
> False

>>> hasattr('', '__iter__') or hasattr('', '__getitem__')
True

> > Also tuples may or may not be considered as iterables,
> > depending on what they are used for.
>
>  >>> hasattr((), '__setitem__')
> False
>  >>> hasattr('', '__setitem__')
> False

What does __setitem__ have to do with iterability ?




More information about the Python-list mailing list