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


Groups > comp.lang.python > #102318

Re: Cannot step through asynchronous iterator manually

Path csiph.com!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 Sun, 31 Jan 2016 09:10:41 +1100
Lines 39
Message-ID <mailman.144.1454191850.2338.python-list@python.org> (permalink)
References <n8hjmt$b8n$1@ger.gmane.org> <CALwzid=sSDSm8hdAN+ORJ54A_jEu9Wc8103iqGKAah8mrj-TXw@mail.gmail.com> <n8hrs1$orn$1@ger.gmane.org> <56AD122F.2030904@gmail.com> <CAPTjJmpGFbnOJGTQcYcFQK83HGCoH5td57J7+RpM_tsR=O3ZOA@mail.gmail.com> <56AD31E7.50407@gmail.com> <56AD3395.8080206@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 3cDlFPEDqZ+4BLDyxmkEKQ/oLfRYrS8s9iDyN5Ll3jog==
Return-Path <rosuav@gmail.com>
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; 'alias': 0.07; 'column': 0.07; 'exception.': 0.07; 'matches': 0.07; 'cc:addr:python-list': 0.09; 'part,': 0.09; 'porting': 0.09; 'rows,': 0.09; 'spec': 0.09; 'sqlite': 0.09; 'throw': 0.09; 'jan': 0.11; 'exception': 0.13; 'ignore': 0.14; '2016': 0.16; 'count,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'query,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'handles': 0.20; 'do.': 0.22; 'not,': 0.22; '31,': 0.22; 'mysql,': 0.22; 'am,': 0.23; 'decide': 0.23; 'select': 0.23; '(or': 0.23; 'this:': 0.23; 'words': 0.24; 'header:In-Reply-To:1': 0.24; 'rest': 0.26; 'message-id:@mail.gmail.com': 0.27; 'found.': 0.27; 'have,': 0.27; 'quoting': 0.29; 'received:209.85.213.174': 0.29; 'there.': 0.30; "i'm": 0.30; 'code': 0.30; 'convention': 0.30; 'query': 0.30; "can't": 0.32; 'says': 0.32; 'run': 0.33; 'michael': 0.33; 'him.': 0.33; 'null': 0.33; 'know.': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'mix': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:209.85.213': 0.37; 'things': 0.38; "won't": 0.38; 'received:209': 0.38; 'someone': 0.38; 'thank': 0.38; 'why': 0.39; 'data': 0.39; 'sure': 0.39; 'whatever': 0.39; 'where': 0.40; 'still': 0.40; 'ever': 0.60; 'your': 0.60; 'skip:n 10': 0.62; 'course': 0.62; 'more': 0.63; 'different': 0.63; 'information': 0.63; 'wish': 0.71; 'frank': 0.72; 'hoping': 0.77; 'chrisa': 0.84; "else's": 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=cM0GdHtov2fLDDO+OYyxMWwrdkXolf6uLsCnTDPakjQ=; b=GDuUNH761M6yxr56AMA/51xejzA7G613u+z/Etf2m/3/Lz1sC9yV/HcKhxTwI9+mut E2Rll4IauphJtiJoAq3BiNpXyMvFlhI8cuTqWjEWPBlJBYMOaQueREUnql/JpUZp8919 h9d/lhyTOZgCypV5TJpgrLeeaBSyhxRlgF1uI23SZdjX67xlVfjNmf0iuatXD+lP/aF+ hIyzFDm7xubBu3XpVrUifUM4AdekXziuJQRpxQTbJQ7nCMAnpPQ6e6bARD0G5sl0j2tc DTaUM52NYQbL3WhMsCw668H4k7U0VOEh63UNODm10BPwBk1W2pljRaLn4McFgwu1qH2q lfAA==
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=cM0GdHtov2fLDDO+OYyxMWwrdkXolf6uLsCnTDPakjQ=; b=E2SVGk4OvPrnVCjMVs/IyErLtQDbbfzbtk1B0FsH6jh6TyMa1UvFD2RBz9Y3pYtavB Z8dTHItJO/u1j3CRX99TDyVfm7SlmFCSsHmeSEQCG63UrixaPt2coi7qGN69IZCIxg19 oL9EwCeKV6RFshVu+rxHxXDeifAa2Tr8bRVIQ7LHUXHLf8zkhU5sBIEyDK8qwqWlTCG/ SZHsH8xby+emsPsk8aBhoBvoV3srWNhvbQKCz7oGjO6z3zFGZDZM8km67Lknu7MI90hD v4yT2+MultKVrLZxshu/Ub5HyY46li0c06FNFMGvX0N+kf6oZ1ODOTkYu8O2FUwgoY2q yUlQ==
X-Gm-Message-State AG10YOTgCAX9+jAimJ+DiR4Q5wDJitYkiIeci6e5mRcyc9h8exwT1UM0WBEwFedA/kd07/NVs1pK0zpxiEo5GQ==
X-Received by 10.50.108.112 with SMTP id hj16mr4027417igb.13.1454191842006; Sat, 30 Jan 2016 14:10:42 -0800 (PST)
In-Reply-To <56AD3395.8080206@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:102318

Show key headers only | View raw


On Sun, Jan 31, 2016 at 9:05 AM, Michael Torrie <torriem@gmail.com> wrote:
> On 01/30/2016 02:57 PM, Michael Torrie wrote:
>> SELECT count(some_id_field),field1,field2,field3 FROM wherever WHERE
>> conditions
>>
>> If the first column (or whatever you decide to alias it as) contains a
>> count, and the rest of the information is still there.  If count is 1,
>> then the row is what you want and you can do whatever you wish with it.
>>  If not, throw your exception.
>
> I'm not sure how SQLite handles it, or even what the SQL spec says, but
> I know in MySQL you could do something like this:
>
> SELECT count(id) as row_count,`tablename`.* FROM `tablename` WHERE condition
>
> and get the same thing as SELECT * would have, with the addition of a
> "row_count" field.  Note that because of the count() part, the query
> will always only return 1 row. The fields will be NULL if the count was
> zero or they will contain the fields from the last row the query found.
>  In other words if there is more than one row that matches the query, it
> will only give you data from the last match.

Huh. Thank you, MySQL, for violating the spec in a different way from
what other servers do. The spec says you can't mix count(id) and
non-aggregated columns; other DBMSes permit this by cloning the ID
down all the rows, not by limiting the result to one row.
(Fortunately, nobody would ever run that on any other DBMS, as you use
the MySQL-specific backticks. Why that non-standard quoting convention
became the normal way to do things in MySQL, I don't know. It's really
annoying when I'm porting someone else's code to PostgreSQL.)

> Now if Frank is hoping to do work on the first row and then throw an
> exception if there's an additional row, then this of course won't work
> for him.

Exactly. If all he wants is to ignore additional rows, it's half the
work - and half the assertion protection.

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-31 09:10 +1100

csiph-web