News for hackers. Stuff that matters.
Re:Reasons for Python async/await by cbsmith on Wednesday May 20, 2015 @06:35PM (#9579818)
The problem I have with async with is that you've already got issues with the syntax for "with" context managers and generators.

    def my_generator():
        with something() as bar:
            for x in baz():
                yield bar(x)  # context manager will call bar.__exit__() before the second time through this loop.
It'd make a LOT more sense to just make "with" understand when it is in a continuation and only invoke __exit__() when the continuation is being destroyed.
Re:Reasons for Python async/await by laurencerowe on Wednesday May 20, 2015 @10:52PM (#9580701)
Are you sure? I only see __exit__() being called after the loop:

    Python 3.4.2 (default, Dec 23 2014, 17:01:26) 
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from contextlib import contextmanager
    >>> @contextmanager
    ... def printme():
    ...     print('enter')
    ...     yield
    ...     print('exit')
    ... 
    >>> def my_generator():
    ...     with printme():
    ...         for x in range(3):
    ...             yield x
    ... 
    >>> for x in my_generator():
    ...     print(x)
    ... 
    enter
    0
    1
    2
    exit
Re:Reasons for Python async/await by rat87 on Thursday May 21, 2015 @05:23AM (#9581674)
I think that's wrong,

    def lazy_lines(filename):
        with open(filename) as f:
            for line in f:
                yield f
works just fine