Perl is worse! (was: Python is Wierd!)
Karl Ulbrich
kulbrich at yahoo.com
Fri Jul 28 02:26:38 EDT 2000
> >Reasonable enough. Though you're not populating a list with a single
> >nothing; you're making an empty list. OTOH, by the logic below, why
> >not [None] instead of []?
>
> Why not indeed? Something other than an error is expected.
No -- if you find that both are possible (and have very-different
meanings) then it's ambiguous, and apart from other issues,
should raise an error (Python *hates* ambiguous).
[] is an empty list.
[ None ] is a single element list with a None obj as the 1st elem.
And while I'm at it, another way to make a single element list:
[].append(123)
More-useful if you need to start with an empty list:
x = []
and later append to it:
x.append(123)
Karl, staying outta the rest of it.
More information about the Python-list
mailing list