Do python's variable length arguments (*args) expand a generator at function call time? -


consider following python code:

def f(*args):     in args:         pass  foo = ['foo', 'bar', 'baz']  # python generator expressions ftw gen = (f f in foo)  f(*gen) 

does *args automatically expand generator @ call-time? put way, iterating on gen twice within f(*gen), once expand *args , once iterate on args? or generator preserved in pristine condition, while iteration happens once during loop?

the generator expanded @ time of function call, can check:

def f(*args):     print(args) foo = ['foo', 'bar', 'baz'] gen = (f f in foo) f(*gen) 

will print

('foo', 'bar', 'baz') 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -