On Sat, Nov 22, 2008 at 10:42 AM, spir <[EMAIL PROTECTED]> wrote:
> I have long thought "[]" /simply/ is a list constructor syntax.

list(x) and [x] are not equivalent, as you have discovered. list(x)
requires that x is a sequence - something that can be iterated - and
it makes a new list  out of the elements of the sequence. If x is not
iterable then list(x) is an error; for example
In [10]: list(1)
TypeError                                 Traceback (most recent call last)
/Users/kent/<ipython console> in <module>()
TypeError: 'int' object is not iterable

OTOH [x] just takes whatever x is and makes it the single element of a list.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to