Implicit lists

Delaney, Timothy tdelaney at avaya.com
Thu Jan 30 23:01:46 EST 2003


> From: Christian Tismer [mailto:tismer at tismer.com]
> 
> In my opinion, the crux of this all is the decision
> that strings are iterable.
> The number of use cases which I have seen so far is much
> shorter than this thread.
> Strings are much more often used as solid objects.
> I'm pretty sure Guido would remove the sequence-ness
> of strings in Python 3000, even to avoid this kind
> of problems.

Whilst I've always liked that strings are iterable in Python, it does lead
to complexity when you want to treat them specially.

Additionally, the new semantics of 'in' for strings in 2.3 does suggest a
lessening of the sequence-like behaviour of strings.

However, there has been a move to making *more* things iterable, not less.
Whilst in general this is nice, it does mean that there are more
opportunities for invalid objects to be processed by library routines.

I would say, if you absolutely *must* have a list, document as such and do a
typecheck. If someone wants to pass a non-list, they must convert it to a
list by whatever method is appropriate.

But in general, wider interfaces are preferable.

Tim Delaney





More information about the Python-list mailing list