[Python-ideas] Star assignment in iterator way?

Kirill Balunov kirillbalunov at gmail.com
Tue Nov 21 06:53:07 EST 2017

May be the first thing which I should do is to improve my English:) My main
point was that in many cases
(in my experience) it is a waste of memory to store entire list for star
variable (*b) instead of some kind
of iterator or deferred evaluation.

How do you defer evaluating the second and subsequent items if you
> evaluate the final two? Given:
> def gen():
>     yield 999
>     for i in range(100):
>         yield random.random()
>     yield 999
>     yield 999
> then
> a, ?*b, c, d = gen()

If I can not copy at Python level, I can 'tee' when 'star_pos' is reached.

In my usual practice, the main use that I encounter when see an assignment
to a star variable is as a storage
which is used only if the other vars match some criterion.

With kind regards, -gdg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171121/3d2b27a1/attachment-0001.html>

More information about the Python-ideas mailing list