Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Frank Millman" Newsgroups: comp.lang.python Subject: Re: Cannot step through asynchronous iterator manually Date: Sat, 30 Jan 2016 14:39:44 +0200 Lines: 31 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de Gvntpa08ZDwMzFFmbnNEBApSvukvuj061G8QH0iw/otw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '-1.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; ':-)': 0.12; 'def': 0.13; 'async': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'select.': 0.16; 'skip:n 70': 0.16; 'sqlite3': 0.16; 'thanks.': 0.18; 'bit': 0.23; 'wrote': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; 'header:X -Complaints-To:1': 0.26; 'solution,': 0.29; 'raise': 0.29; 'something': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'why': 0.39; 'to:addr:python.org': 0.40; 'skip:n 10': 0.62; 'needing': 0.63; 'choose': 0.68; 'frank': 0.72 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 197.86.205.12 In-Reply-To: X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 15.4.3502.922 X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3502.922 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102299 "Maxime S" wrote in message news:CAGqiJR8yUdd1u7j0YHS-He_v4uUT-ui=PpiX=n_G=ntt8ZnTpg@mail.gmail.com... > > I might be a bit off-topic, but why don't you simply use cursor.rowcount? > I just tried that on sqlite3 and pyodbc, and they both return -1. I think that it only works with insert/update/delete, but not with select. > For a pure iterator-based solution, I would do something like this > (admitly > a bit cryptic, but iterator-based solutions often are :-) : > > async def get_uniqu(ait): > async for row in ait: > break > else: > raise NotEnoughtRows() > async for _ in ait: > raise TooManyRows() > return row > Also nice - thanks. I now have a few to choose from without needing an 'anext()'. Frank