Velocity Reviews

Velocity Reviews (
-   Python (
-   -   Re: it's really does it work? (

Chris Rebert 08-15-2012 05:24 AM

Re: it's really does it work?
On Tue, Aug 14, 2012 at 10:07 PM, levi nie <> wrote:
> ok,what does "start, stop = 0, start" in the code mean?
> it's really does it work?

It's just parallel assignment

As to exactly how it works: :
"If the target [of the assignment] is a comma-separated list: The
[value being stored] must be an iterable with the same number of items
as there are targets in the target list, and the items are assigned,
from left to right, to the corresponding targets." [not a completely
direct quote]

Tuples are iterable (e.g. we can write `for item in some_tuple:`; in
laymen's terms, it's similar to being a sequence). Recall that commas,
and not parentheses, are what create tuples according to Python's
$ python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1,2
>>> x

(1, 2)
>>> type(x)

<type 'tuple'>

So, your code snippet creates an anonymous temporary tuple of length 2
[i.e. (0, start) ], and the assignment then unpacks that tuple into
the 2 respective variables.


All times are GMT. The time now is 02:10 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.