Python Forum

Full Version: a proxy function for a generator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
suppose i have a generator named g(). i create a function named f() that when called with keyword argument gen=True will call g(*args,**kwargs) and return whatever it gets. can f() be used like a generator when give that keyword argument?

i want to have a single API function that can be a regular function or a generator depending on a given argument.