Perl is worse!

Martijn Faassen m.faassen at vet.uu.nl
Fri Jul 28 16:41:31 EDT 2000


Steve Lamb <grey at despair.rpglink.com> wrote:
[snip]
>     Ah, but getting back to that point I said to remember.

> foo = "a"
> foo = list(foo)

>     foo is not ['a'].  It took a single element and made it a list.  So we now
> know that a single element has a sequence.  Here is another sequence of a
> single element.

> foo = 1
> foo = list(foo)

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

Ahum, now watch this:

foo = 1
foo = foo + 1

foo is now 2. So, '+ 1' takes a single integer and makes it the number 2. So
now we know that a single integer is turned into 2 that way. Here's another
integer:

foo = 3
foo = foo + 1

Foo is now 4! But we just determined + 1 turned something into 2, right? :)

Your reasoning is faulty. In Python, a string is a sequence. That's why
list("a") works. It turns a string sequence of characters into a list
sequence of characters (or strings, in fact, as characters and strings
are the same in Python).

Please, do find the inconsistencies and quirks of Python _where they 
actually are_. Most of what you're finding *is* consistent and is not
a quirk. It's merely different than what you're used to. The only
real quirk you found is None = 1, and even that is a consequence of
a consistency.

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list