The easy way to do this is to step outside the interpreter and just search the docs.
Meanwhile, it looks to me like there is no such function to import. There are group_by
methods on sqlalchemy.orm.query.Query
and sqlalchemy.sql.expression.[Compound]Select[Base]
objects.
But if you really want to recursively walk through all the modules in a package looking for a name, here's how you'd do it:
import inspect
def find_name(package, name):
if hasattr(package, name):
yield package
for modulename, submodule in inspect.getmembers(package, inspect.ismodule):
yield from find_name(submodule, name)
For Python 3.2 or earlier, you need to replace the yield from
with a loop:
for modulename, submodule in inspect.getmembers(package, inspect.ismodule):
for result in find_name(submodule, name):
yield result
And if you just want the first result, instead of all results, you can just return
instead of yield
ing:
def find_name(package, name):
if hasattr(package, name):
return package
for modulename, submodule in inspect.getmembers(package, inspect.ismodule):
result = find_name(submodule, name)
if result:
return result