On Tue, Nov 15, 2011 at 4:44 PM, Chris Nelson <[email protected]>wrote:

> In estimation tools, workload.py does "from estimationtools.utils import
> ...".  When I copied that style and had my tracjsgantt.py do "from
> tracjsgantt.tracpm import TracPM", I get the error above.  When I make it
> "from tracpm import TracPM", it works!  I have no idea why but running code
> trumps documentation and examples so I'm not going to complain.
>

Probably it's failing because you have a tracjsgantt.py file in the
tracjsgantt directory.  So when you say "from tracjsgantt.tracpm import
TracPM", Python finds the tracjsgantt.py file first, and gets confused.  If
you renamed tracjsgantt.py to something else, the import would probably do
what you're expecting.

(I'm using a lot of "probablys" because the actual details of this depend
on your `sys.path`, which is very environment-specific.)

The "from tracpm import TracPM" is most likely succeeding because your
Python is using implicit relative imports, but might also have to do with
your sys.path and current working directory when you run the code.

http://docs.python.org/whatsnew/2.5.html#pep-328 and
http://djangotricks.blogspot.com/2008/09/note-on-python-paths.html are good
reading on the two major aspects here (relative vs absolute imports, and
the import search path)

-Ethan

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en.

Reply via email to