1

I have a file structure:

A
|
main.py
|_B
  |a_funcs.py

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

I tried dir(a_func) but that says a_func is not defined.

user1234440
  • 22,521
  • 18
  • 61
  • 103

1 Answers1

3

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.

bpachev
  • 2,162
  • 15
  • 17