run all scripts in sub-directory as subroutines?

ryles rylesny at
Thu Aug 13 03:25:40 CEST 2009

On Aug 11, 5:12 pm, guthrie <guth... at> wrote:
> This works fine, but in the sub-modules the sys.path appropriately
> returns the same as from the parent, I want them to know their own
> file names. How?? I can pass it to them, but wondered if there is a
> more self-sufficient way for a module to know from where it was
> invoked.

Instead of sys.path, you may be interested in the __file__ attribute
will give you a module's filename:

You could also be more explicit in matching *.py files in your
subdirectory by using glob:

More information about the Python-list mailing list