Perl is worse! (was: Python is Wierd!)

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Mon Jul 31 09:36:14 EDT 2000


Steve Lamb wrote in comp.lang.python:
> foo = 1
> foo = list(foo)
> 
>     Error.  Single element sequence.

1 is not a single element sequence, because it has no elements: 1[0] gives
an error.

"1" is a sequence, and its first element, "1"[0], is "1".

It's really quite simple.

The list() function takes any sequence and produces a list with the same
elements as the sequence.

Constructing a list from zero or more values is done with the [ ] "operator":
to make a list out of the integer 1, that is the list with one element of
value 1, you use [1].

> Remember, any sequence can either be a
> single value or a sequence.  Yet here we have a single value denied.  Quirks
> abound.

Sequences can be seen as a single value or as a sequence of values. But that
doesn't imply that any single value can be seen as a sequence. Simple logic.

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
"This gubblick contains many nonsklarkish English flutzpahs, but the
 overall pluggandisp can be glorked from context"  (David Moser)



More information about the Python-list mailing list