Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #14935
| From | John Gordon <gordon@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Importing a module from a non-cwd |
| Date | 2011-10-24 20:38 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <j84ica$94j$1@reader1.panix.com> (permalink) |
| References | <4ea5c1da$0$3708$426a74cc@news.free.fr> |
In <4ea5c1da$0$3708$426a74cc@news.free.fr> candide <candide@free.invalid> writes:
> For instance, suppose I have a file, say my_file.py, located in the cwd,
> say /home/candide/ and suppose the module to be imported, say
> my_module.py, is located in the /home/candide/foo/ directory.
> How my_file.py can import the my_module.py module ?
If PYTHONPATH and/or sys.path contain /home/candide/foo/, then you should
be able to:
import my_module
Or, if foo/ is a real module (i.e. it contains an __init__.py file), this
should work:
import foo.my_module
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Importing a module from a non-cwd candide <candide@free.invalid> - 2011-10-24 21:51 +0200 Re: Importing a module from a non-cwd John Gordon <gordon@panix.com> - 2011-10-24 20:38 +0000
csiph-web