user1234440 user1234440 - 1 year ago 72
Python Question

List All functions in file Python

I have a file structure:


is the main folder while
is a sub-folder inside
. In my
filer, I have
from B.a_funcs import *
. This statement imports all functions from the
file. Is it possible to list out all the functions inside that
file`? How do I do that?

I tried
but that says a_func is not defined.

Answer Source

That is because you didn't explicitly import the name a_func. Instead of from B.a_func import * (which creates potential namespace collisions) do from B import a_func, and then call functions with a_func.. This is better practice, and will let you do what you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download