Calling coroutine from coroutine in python -


i came across issue today , i'm not quite why works this:

def outside():     print 'before'     inside()     print 'after'     yield 'world'  def inside():     print 'inside'     yield 'hello'  n in outside():     print n 

(naive) expectation of output:

before inside hello after world 

actual output:

before after world 

is not possible call coroutine inside coroutine? articles read on coroutines , yield didn't elaborate on issue , i'm quite lost here. shed light on behaviour please? in advance!

it totally possible. when call inside() creates coroutine. in order yield result, need initialize coroutine , yield follows:

def outside():      print 'before'      in inside():          yield      print 'after'      yield 'world' 

and result expected:

before inside hello after world 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -