{"action":"created","issue":{"url":"https://api.github.com/repos/python/peps/issues/684","repository_url":"https://api.github.com/repos/python/peps","labels_url":"https://api.github.com/repos/python/peps/issues/684/labels{/name}","comments_url":"https://api.github.com/repos/python/peps/issues/684/comments","events_url":"https://api.github.com/repos/python/peps/issues/684/events","html_url":"https://github.com/python/peps/pull/684","id":335159525,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2OTM3NTE4","number":684,"title":"PEP 572: handle comprehension edge cases","user":{"login":"ncoghlan","id":1026649,"node_id":"MDQ6VXNlcjEwMjY2NDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1026649?v=4","gravatar_id":"","url":"https://api.github.com/users/ncoghlan","html_url":"https://github.com/ncoghlan","followers_url":"https://api.github.com/users/ncoghlan/followers","following_url":"https://api.github.com/users/ncoghlan/following{/other_user}","gists_url":"https://api.github.com/users/ncoghlan/gists{/gist_id}","starred_url":"https://api.github.com/users/ncoghlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ncoghlan/subscriptions","organizations_url":"https://api.github.com/users/ncoghlan/orgs","repos_url":"https://api.github.com/users/ncoghlan/repos","events_url":"https://api.github.com/users/ncoghlan/events{/privacy}","received_events_url":"https://api.github.com/users/ncoghlan/received_events","type":"User","site_admin":false},"labels":[{"id":393407713,"node_id":"MDU6TGFiZWwzOTM0MDc3MTM=","url":"https://api.github.com/repos/python/peps/labels/CLA%20signed","name":"CLA signed","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-06-24T07:48:50Z","updated_at":"2018-06-30T04:59:45Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/python/peps/pulls/684","html_url":"https://github.com/python/peps/pull/684","diff_url":"https://github.com/python/peps/pull/684.diff","patch_url":"https://github.com/python/peps/pull/684.patch"},"body":"The stateful comprehension examples mishandled a couple of edge cases:\r\n\r\n- they didn't detect the \"no input\" case (reporting it as \"no comments\"\r\n  or \"no blank lines\")\r\n- the chosen target names only made sense when the any() or all()\r\n  operations returned True - this switches them to use a more neutral\r\n  name that doesn't make any assumptions about the overall result"},"comment":{"url":"https://api.github.com/repos/python/peps/issues/comments/401517506","html_url":"https://github.com/python/peps/pull/684#issuecomment-401517506","issue_url":"https://api.github.com/repos/python/peps/issues/684","id":401517506,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTUxNzUwNg==","user":{"login":"ncoghlan","id":1026649,"node_id":"MDQ6VXNlcjEwMjY2NDk=","avatar_url":"https://avatars3.githubusercontent.com/u/1026649?v=4","gravatar_id":"","url":"https://api.github.com/users/ncoghlan","html_url":"https://github.com/ncoghlan","followers_url":"https://api.github.com/users/ncoghlan/followers","following_url":"https://api.github.com/users/ncoghlan/following{/other_user}","gists_url":"https://api.github.com/users/ncoghlan/gists{/gist_id}","starred_url":"https://api.github.com/users/ncoghlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ncoghlan/subscriptions","organizations_url":"https://api.github.com/users/ncoghlan/orgs","repos_url":"https://api.github.com/users/ncoghlan/repos","events_url":"https://api.github.com/users/ncoghlan/events{/privacy}","received_events_url":"https://api.github.com/users/ncoghlan/received_events","type":"User","site_admin":false},"created_at":"2018-06-30T04:59:45Z","updated_at":"2018-06-30T04:59:45Z","author_association":"CONTRIBUTOR","body":"The problem I have with the original example being used as motivation in a PEP is that it's *exactly* the kind of code that looks pretty, but encourages the introduction of latent defects that are easy to miss on code review:\r\n\r\n- Can the base iterable ever be empty? (For something like small primes, no, but for iterating over lines in a file, absolutely)\r\n- Can subsequent refactoring end up referencing the bound name in a context where it isn't actually semantically valid to do so? (In the current PEP examples yes, as the target name is bound *before* the filter condition is evaluated, but the chosen name implies that it's only bound when the filter condition is true)\r\n\r\nIf the PEP wants to present a truly compelling case for itself, it shouldn't be using potentially bug-prone code to do it.\r\n\r\nAnd if the non-bug-prone version is enough to make proponents say \"I wouldn't want to use it if I had to actually handle the edge cases properly\", then the fact that people only like the bug prone version is an important data point."}}
{"actor":{"display_login":"ncoghlan"}}