what does 'for _ in range()' mean?
peter at engcorp.com
Wed Jul 28 21:28:45 CEST 2004
Phil Frost wrote:
> (fu, bar, _, __) = returns_a_4_tuple()
> One difference is that _ is allowed multiple times in Ocaml, while in
> Python it is not.
Why do you say that?
Python 2.3.4 (#53, May 25 2004, 21:17:02) ....
>>> a = 1, 2, 3, 4
>>> b, c, d, e = a
>>> b, c, d, d = a
>>> b, c, _, _ = a
>>> _, _, _, _ = a
Looks to me like Python doesn't care how many times it rebinds
a name while unpacking a tuple.
More information about the Python-list