run all scripts in sub-directory as subroutines?
ryles
rylesny at gmail.com
Wed Aug 12 21:25:40 EDT 2009
On Aug 11, 5:12 pm, guthrie <guth... at mum.edu> 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:
http://docs.python.org/reference/simple_stmts.html#index-1031
You could also be more explicit in matching *.py files in your
subdirectory by using glob:
http://docs.python.org/library/glob.html
More information about the Python-list
mailing list