By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

how to absolute import?

P: n/a
>From Guido's PEP8:

- Relative imports for intra-package imports are highly
discouraged. Always use the absolute package path for all
imports.

Does it mean I should put my develop directory into PYTHONPATH (e.g.
/home/hongqn/devel/python) and use "import myproj1.package1.module1 as
module1" all the way? Or should I make a "./setup.py install" for
every package whenever I made a change?

I'm using python 2.3 so from .foo import bar doesn't work for me.

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Qiangning Hong wrote:
From Guido's PEP8:
- Relative imports for intra-package imports are highly
discouraged. Always use the absolute package path for all
imports.

Does it mean I should put my develop directory into PYTHONPATH (e.g.
/home/hongqn/devel/python) and use "import myproj1.package1.module1 as
module1" all the way? Or should I make a "./setup.py install" for
every package whenever I made a change?


Yes. =) Either one of those is a reasonable solution. I tend to put
local modules that I don't expect to distribute (but that I use
frequently) on my PYTHONPATH, but actually building them as a package is
certainly a reasonable solution too.
I'm using python 2.3 so from .foo import bar doesn't work for me.


This doesn't work in 2.4 either. ;)

STeVe
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.