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

How to import X from Python library when X is defined in a package

P: n/a

OK, here's the setup:



Now inside package, we want to import the copy
of defined in python/lib/.

In C one would do #include <X>

In Python, the easiest solution is:

Make a subpackage called pylibs


In package/pylibs/, do import X.

Then to get X from within package, just do

import package.pylibs.X

The more obvious solutions (such as doing
sys.path.reverse(); import X; sys.path.reverse()
inside the package) do not work, because Python
ignores sys.path
when inside a package (ie it always looks in the
package directory even when told explicitly not to).

Anyway, this is the workaround that I found, and it
works fine.

- Connelly

Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.