On Sat, Oct 11, 2008 at 13:13, didier deshommes <[EMAIL PROTECTED]> wrote: > > On Sat, Oct 11, 2008 at 1:50 PM, Ondrej Certik <[EMAIL PROTECTED]> wrote: >>> as soon as someone realizes that in CPython it is possible to speed up >>> iteration over strings by creating a stringiterator type, then CPython >>> will grow a 'str.__iter__' as well, and the same infinite recursion will >>> occur in sympy... >>> >>> A cleaner way to say "is x iterable?" would be to try to call iter(x) >>> and see if it raises TypeError or not. >> >> Indeed, thanks very much for the tip. We'll fix that, that's >> definitely something that should be fixed in sympy, I created a new >> issue for that: > > Hi, > I've faced the same problem and checking if x has the __getitem__ > attribute has worked for me. The rationale being that any iterable has > a way to access its individual items.
That's not true at all. The whole point of __iter__ is to allow iterables that do not need to allow access via __getitem__. Generators, file objects, probably all of the iterables from itertools, and many more do not have __getitem__. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
