On 29 June 2013 00:22, <jimjhb@aol.com> wrote:
The takewhile syntax is kind of god awful. The lambda thing always gives me pause, though I now 'grok' the whole thing to be a conditional. I don't think the issue is about added complexity to the comprehension (as the added clause would be optional anyway)
Note that this is a misunderstanding of what "added complexity" means in a language design context. More options almost always mean more complexity. The only way adding more options can simplify things in a practical sense is when they shift complexity from user code to the interpreter implementation by extracting an existing common pattern and giving it dedicated syntax (such as comprehensions, generator expressions and "with" statements), or when they provide a corrected alternative to an existing tempting-but-wrong construct (such as "a if p else b" replacing the "p and a or b" hack and "yield from itr" replacing the coroutine incompatible "for x in itr: yield x"). In this case, the proposal is only tinkering at the edges - you can *always* handle it by creating a custom generator instead. All this proposal does is subtly adjust the point at which it becomes more attractive to write a custom generator function than it is to do the operation in line in the comprehension or generator expression. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia