The generator is expanded at the time of the function call, as you can easily check:
def f(*args):
print(args)
foo = ['foo', 'bar', 'baz']
gen = (f for f in foo)
f(*gen)
will print
('foo', 'bar', 'baz')
More Related Contents:
- What exactly are iterator, iterable, and iteration?
- How are lambdas useful? [closed]
- Apply function to each element of a list
- python max function using ‘key’ and lambda expression
- Why does Python code use len() function instead of a length method?
- Calling variable defined inside one function from another function
- Split a generator into chunks without pre-walking it
- Why do some functions have underscores “__” before and after the function name?
- Defining private module functions in python
- Intersecting two dictionaries
- How to pass an operator to a python function?
- How can I pass information (a variable) out of a function? How can I use that from outside, e.g. in other functions?
- How do I pass variables across functions?
- Why is this python generator returning the same value everytime?
- Is it pythonic for a function to return multiple values?
- How to pass dictionary items as function arguments in python? [duplicate]
- What is the difference between raise StopIteration and a return statement in generators?
- int([x[, base]]). Square brackets in functions in Python documentation? [duplicate]
- function is not defined error in Python
- Why is “None” printed after my function’s output?
- How does Python return multiple values from a function?
- Is it possible to not return anything from a function in python? (What happens if the function reaches the end without `return`ing?)
- Convert generator object to list for debugging [duplicate]
- Why can’t generators be pickled?
- Customizing unittest.mock.mock_open for iteration
- Use a string to call function in Python [duplicate]
- Are functions objects in Python?
- Defining a default argument as a global variable
- How can I count the number of items in an arbitrary iterable (such as a generator)?
- python pandas- apply function with two arguments to columns