[off-topic] Re: What do perl lovers like about python?

Tara L Andrews chrysaphi at gmail.com
Wed Aug 22 15:58:14 BST 2007


On 22 Aug 2007, at 15:41, Nigel Rantor wrote:

> Otávio Fernandes wrote:
>> David,
>> In past months I learned python, its very useful, but the most
>> interesting thing in my opinion is module calling (importing) its  
>> very
>> easy.
>
> In that case can you let me know how you get two seperate libraries  
> to hold modules with a common root namespace?
>
> You can only have a single __init__.py and the first one to be  
> found wins.

You re-write the import functions to have the logic you think it  
should have.  I actually had to do this at my last job, to make

import dept.subtree1.module1
import dept.subtree1.module2

work the same as
use Dept::Subtree::Module1;
use Dept::Subtree::Module2;

where the directory structure was ".../dept/subtree1/pylib/dept/ 
subtree1/module1" and so forth.

That said, I managed to make this work in about a day, when I hadn't  
programmed anything in Python for four years (and wasn't very good at  
it back then.)  All that matters is that "dept.subtree.module1" has  
the right pointer to the right __init__.py, in the end; you can make  
it not matter were it thinks "dept/subtree/__init__.py" is.

-tara


More information about the london.pm mailing list