Argument against iterable ints...

Magnus Lie Hetland mlh at vier.idi.ntnu.no
Sun Apr 7 14:09:49 EDT 2002


In article <mailman.1018117586.26522.python-list at python.org>, James
Althoff wrote:
[snip]
>Magnus,
>
>I don't see how the above is even recursive, much less infinitely recursive.
>Could you elaborate?

def flatten(seq):
    try: iter(seq)
    except: yield seq
    else:
        for sub in seq:
            for item in flatten(sub):
                yield item

Anyway, I guess I shouldn't frame this as an argument against the
rejected PEP -- but rather _for_ a char type (to avoid having the
string "s" consist of the string "s" which again consists of the
string "s" etc., instead of consisting of the char 'c' which is not a
sequence...) But with the uproar against bool, I dare not do so ;)

>Jim

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org



More information about the Python-list mailing list