General question about Python design goals

Fredrik Lundh fredrik at pythonware.com
Thu Dec 1 03:09:41 EST 2005


Mike Meyer wrote:

> So why the $*@& (please excuse my Perl) does "for x in 1, 2, 3" work?

because the syntax says so:

    http://docs.python.org/ref/for.html

> Seriously. Why doesn't this have to be phrased as "for x in list((1,
> 2, 3))", just like you have to write list((1, 2, 3)).count(1), etc.?

because anything that supports [] can be iterated over.

</F>






More information about the Python-list mailing list