The call X() invokes X.__new__() (a class method), and that class
method returns the instance which is then passed as the self argument
to __init__.

So asynchronous object creation should be done by a factory coroutine,
and not by calling the standard constructor machinery.

Best,

Luciano


On Sat, May 16, 2015 at 10:08 AM, Imran Geriskovan
<[email protected]> wrote:
> Or am I doing something wrong?
> X does not run. Y runs.
> Thanks for comments..
>
> x = yield from X()  # Does not work
> y = Y()                 # Works..
> yield from y.init()
>
> class X:
>     def __init__():
>         yield from some async code
>
> class Y:
>     def __init__():
>        some sync code
>
>     def init():
>         yield from some async code



-- 
Luciano Ramalho
|  Author of Fluent Python (O'Reilly, 2015)
|     http://shop.oreilly.com/product/0636920032519.do
|  Professor em: http://python.pro.br
|  Twitter: @ramalhoorg

Reply via email to