Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102285

Re: Cannot step through asynchronous iterator manually

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Cannot step through asynchronous iterator manually
Date Sat, 30 Jan 2016 19:09:26 +1100
Lines 33
Message-ID <mailman.115.1454141369.2338.python-list@python.org> (permalink)
References <n8hjmt$b8n$1@ger.gmane.org> <CALwzid=sSDSm8hdAN+ORJ54A_jEu9Wc8103iqGKAah8mrj-TXw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de yl3rw1DCzCltrSiaRb4pfQntZ9KT+WOfRLV8ZKF7fZsg==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'higher-level': 0.09; 'loop.': 0.09; 'yeah,': 0.09; 'python': 0.10; 'jan': 0.11; 'question.': 0.13; 'times,': 0.13; '2016': 0.16; 'async': 0.16; 'cc:name:python': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterating': 0.16; 'iterator': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'wrote:': 0.16; 'skip': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'file.': 0.22; 'pass': 0.22; 'sat,': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'header': 0.24; 'rest': 0.26; 'equivalent': 0.27; 'message- id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'regular': 0.29; "i'm": 0.30; 'common': 0.33; 'usually': 0.33; 'received:google.com': 0.35; 'expected': 0.35; 'step': 0.36; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'desired': 0.37; 'missing': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'sure': 0.39; 'skip:n 10': 0.62; '30,': 0.63; "'for'": 0.84; 'chrisa': 0.84; 'construct': 0.84; 'to:none': 0.91
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:cc :content-type; bh=OVSvGX+EckKaLx09QKrNbN2gHogLDvzvRRpi0f4jg9M=; b=GBSbBVHCD1iNu8MFk24354WZ1SUQEuwKjzIwfDHirqyDtbBIjPl7kyBDNsWhIEsqtw SCyD9l2WfwBPvpNW4GENBkztuKHnujUtzJD6Zb29TXoMvxrgNzSMp8+vrXNNHtGLXjcY /mwbT4xerO/J3NkRWCWZiY5SLS3wTu2D1Jsa0uIlhvaACh8w15g1icTUbvpT9vkAGPi8 lj8jwclQVAasb3g3adyfhsNFr3iGMDUPRCzKeSGNKhp0d/VqSR9G727FkWwAmdU67GnG 6YMr7SPKDhi5ubJyQ1u6KKZIxC9C6oHdYCd+p1xpQ7bIhEkW4/kKwo9yS791X2zL/BNI 85gw==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc:content-type; bh=OVSvGX+EckKaLx09QKrNbN2gHogLDvzvRRpi0f4jg9M=; b=QQAdbVTRxViEIART4QL6JmWv6jsBeTCkLM4qLnUQUSfDWFvm3j8Zx1swtESRdnd6l2 1NB5/4ixFsL52RuCGq4EyGGiqPzeLc8XkY67LUmDW9ASNCISKUr5vefkYcCaYWfBStuz UhEKfqq0FsrhvcLHibJF00IUgV+jZSKyYW/hiFf8bwzPQKLTsGN8RdZwC94zwJTR8y1F KCLD1SjVA8rsB7KTlEYzVlnbOEyQIenYMrznwpz0ZXLYonQiDGaGo51RUrzirGGfxuMi +vSPPwwIM+C0mGgnJY5+UfrJFrWliM0520cGDNB9uGb6aQIBJvPefsf1AGxTBFJ9cdxq F1TQ==
X-Gm-Message-State AG10YOSc34nTsEUEtJnzHAXg7pkqB+SDdigJWzqdp23UiK8gw0UoI3JKbVoqHhIJyjowXFqq8i3Nu5B2syP86A==
X-Received by 10.50.28.105 with SMTP id a9mr1401775igh.94.1454141366130; Sat, 30 Jan 2016 00:09:26 -0800 (PST)
In-Reply-To <CALwzid=sSDSm8hdAN+ORJ54A_jEu9Wc8103iqGKAah8mrj-TXw@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:102285

Show key headers only | View raw


On Sat, Jan 30, 2016 at 7:02 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Jan 29, 2016 11:04 PM, "Frank Millman" <frank@chagford.com> wrote:
>>
>> Hi all
>>
>> To loop though an iterator one usually uses a higher-level construct such
> as a 'for' loop. However, if you want to step through it manually you can
> do so with next(iter).
>>
>> I expected the same functionality with the new 'asynchronous iterator' in
> Python 3.5, but I cannot find it.
>>
>> I can achieve the desired result by calling 'await aiter.__anext__()',
> but this is clunky.
>>
>> Am I missing something?
>
> async for x in aiter:
>     pass

Yeah, he wants to single-step it. A regular for loop is equivalent to
calling next() lots of times, and you can manually call next(). Common
usage: Skip a header row before iterating over the rest of a file. So
how do you do the same thing with an async iterator? I'm not sure
there's a way, currently. That's the question.

Of course, you can always do this:

async for x in aiter: break

as an equivalent to "x = next(aiter)", but that's just stupid :)

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Cannot step through asynchronous iterator manually Chris Angelico <rosuav@gmail.com> - 2016-01-30 19:09 +1100

csiph-web