Movatterモバイル変換
[0]ホーム
[Python-Dev] Tricky way of of creating a generator via a comprehension expression
Paul Moorep.f.moore at gmail.com
Wed Nov 22 11:16:42 EST 2017
On 22 November 2017 at 16:08, Ivan Levkivskyi <levkivskyi at gmail.com> wrote:> On 22 November 2017 at 16:56, Yury Selivanov <yselivanov.ml at gmail.com>> wrote:>>>> On Wed, Nov 22, 2017 at 10:10 AM, Ivan Levkivskyi <levkivskyi at gmail.com>>> wrote:>> > On 22 November 2017 at 15:47, Paul Moore <p.f.moore at gmail.com> wrote:>> [...]>> I'm all for prohibiting using 'yield' expression in generator>> expressions or comprehensions. The semantics is way to hard to>> understand and hence be of any value.>>>> Making 'await' a SyntaxError is absolutely not an option. Async>> generator expressions are a shorthand syntax for defining asynchronous>> generators (PEP 525), and it's already being used in the wild.>>> OK, makes sense, so it looks like we may have the following plan:>> - fix `yield` in comprehensionsI'm still not clear what "fix" would actually mean, but you proposeclarifying the docs below, so I assume it means "according to whateverthe updated docs say"...> - update PEP 530 and docs re generator expressions vs comprehensionsDocs more importantly than PEP IMO. And are you implying that there'sa difference between generator expressions and comprehensions? Ithought both were intended to behave as if expanded to a functioncontaining nested for loops? Nothing said in this thread so far (aboutsemantics, as opposed to about current behaviour) implies there's adeliberate difference.> - make `yield` in generator expressions a SyntaxErrorThat contradicts the suggestion that generator expressions areequivalent to the expanded function definition we saw before.> If everyone agrees, then I propose to open a separate issue on b.p.o. to> coordinate the efforts.I agree it needs clarifying. Not sure I agree with your proposedsemantics, but I guess that can wait for when we have a concrete docchange proposal.Paul
More information about the Python-Devmailing list
[8]ページ先頭