[Python-3000] callable()

Brett Cannon brett at python.org
Fri Jul 21 03:31:14 CEST 2006


On 7/20/06, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> Walter Dörwald wrote:
>
> > I don't know about __call__, but str and unicode don't have __iter__,
> > list, tuple and dict do:
>
> That's probably because str and unicode don't do their
> own iteration, but rely on the fallback implementation.
> In which case it's perfectly correct for them not to
> have an __iter__ method.
>
> If you want to test whether something is iterable, it's
> not enough to test for __iter__ -- you also need to
> test for __len__ and __getitem__ as an alternative.
> Which means it might make sense to have an iterable()
> function which does that.
>
> --
> Greg
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/brett%40python.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060720/f33858ac/attachment.html 


More information about the Python-3000 mailing list