[Tutor] PYTHONPATH (Mac OS X)

Stayvoid stayvoid at gmail.com
Tue Dec 20 02:33:58 CET 2011


> Please clarify, or expand, or tell us what problem you are having or
> trying to solve.

Hi!

I want to have a possibility to import modules from the folder, which
is not included in the load path.

Example:

module.py
---------
def testfunc(name):
  file = open(name)
  return len(file.readlines())

if __name__ == "__main__":
  print testfunc(module.py)

Code listing (shell):
python /Users/Username/pythonmodules/module.py

NameError: name 'module.py' is not defined

Kind regards.


More information about the Tutor mailing list