Received: from localhost (HELO mail.python.org) (127.0.0.1)
by albatross.python.org with SMTP; 05 Jul 2014 03:19:08 +0200
Received: from mail-la0-x235.google.com (unknown
[IPv6:2a00:1450:4010:c03::235])
(using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits))
(No client certificate requested)
by mail.python.org (Postfix) with ESMTPS
for <python-ideas-+ZN9ApsXKcEdnm+***@public.gmane.org>; Sat, 5 Jul 2014 03:19:08 +0200 (CEST)
Received: by mail-la0-f53.google.com with SMTP id b8so1535652lan.12
for <python-ideas-+ZN9ApsXKcEdnm+***@public.gmane.org>; Fri, 04 Jul 2014 18:19:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:cc:content-type;
bh=Uhkt/2HaJcfkhfj4o+/w8MHTwLyQX9vSoIndcIBbjJ4=;
b=tY/fTX4MCGw3TE95bO11TB/nn+LJzbPIoJMkeUQ3K6rEXexx2WdThKyWtP8Y7MF23o
5puYlJlS/IKfHMdt/PLJ4RPf6k5YRmjmc2YtP/bIDEcPluwBzEDHCwV72qX641gUmngB
sVYjhSmZ3tU01Iu/Oldgx1UF0TIhSJOMr+P/TMj/uPHKnJYQtDlGtRIBcdTwbaQTODFT
VtuNvMmAkxpqfuWXqrRt9RfAa5vS3jObeeDTdkuNOYvK0LSgBu7zAu8le9A2Nsa1AXh2
TIKdeDAZH6eXmsrL6cMD2tDR7Ce+WhMRFXnb3KJhKpx6Aq5K79hQymcLUwwMQAJqYFjD
HS/w==
X-Received: by 10.112.180.70 with SMTP id dm6mr10494873lbc.32.1404523141688;
Fri, 04 Jul 2014 18:19:01 -0700 (PDT)
Received: by 10.112.137.225 with HTTP; Fri, 4 Jul 2014 18:19:01 -0700 (PDT)
In-Reply-To: <20140705005930.GA7612-***@public.gmane.org>
X-BeenThere: python-ideas-+ZN9ApsXKcEdnm+***@public.gmane.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Discussions of speculative Python language ideas
<python-ideas.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-ideas>,
<mailto:python-ideas-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-ideas/>
List-Post: <mailto:python-ideas-+ZN9ApsXKcEdnm+***@public.gmane.org>
List-Help: <mailto:python-ideas-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-ideas>,
<mailto:python-ideas-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=subscribe>
Errors-To: python-ideas-bounces+gcpi-python-ideas=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org
Sender: "Python-ideas"
<python-ideas-bounces+gcpi-python-ideas=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.python.ideas/28303>
Post by Paul Tagliamonte... yield y
...
a, b, c, *others = g_range(100)
Works great. Super useful stuff there. Looks good.
I also notice that this causes *others to consume the generator
in a greedy way.
<class 'list'>
And this makes me sad.
a, b, c, *others = g_range(10000000000)
# will also make your machine very sad. Eventually resulting
Killed
_x = g_range(1000000000000)
a = next(_x)
b = next(_x)
c = next(_x)
others = _x
Of course, this leads to all sorts of fun errors, like the fact you
couldn't iterate over it twice. This might not be expected. However, it
might be nice to have this behavior when you're unpacking a generator.
Thoughts?
I agree that the behaviour is suboptimal, but as Chris already pointed
out it would introduce a significant inconsistency in the API of
unpacking. I'm struggling to see a *good* way of doing this. My first
instinct was that we could make something like this do what you
Post by Paul Tagliamontea, b, c, others = g_range(some_really_big_number)
others
<generator ...>
But this doesn't work like this currently because Python currently
raises a ValueError because there were too many values to unpack. I'm
also against introducing some new syntax to add the behaviour.