it's really strange.how does it work?

Ramchandra Apte maniandram01 at gmail.com
Wed Aug 15 01:18:32 EDT 2012


Even I got confused a bit:
explaination: this is called iterable unpacking
`start, stop = 0, start` is the same as:
temp = start
start = 0
stop = temp
On 15 August 2012 10:37, levi nie <levinie001 at gmail.com> wrote:
> ok,what does "start, stop = 0, start" in the code mean?
> it's really strange.how does it work?
>> code:
> def interval(start, stop=None, step=1):
> 'Imitates range() for step > 0'
> if stop is None:
> start, stop = 0, start
> result = []
> i = start
> while i < stop:
> result.append(i)
> i += step
> return result
>> print interval(10)
>> --
> http://mail.python.org/mailman/listinfo/python-list
>>-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120815/b50b972f/attachment.html>


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /