modules and generated code

J. Clifford Dyer webmaster at
Wed Nov 15 18:08:30 CET 2006

Nigel Rantor wrote:
> Peter Otten wrote:
>> Nigel Rantor wrote:
>>> Peter Otten wrote:
>>>> Nigel Rantor wrote:
>>>>> So, if I have a tool that generates python code for me (in my case,
>>>>> CORBA stubs/skels) in a particular package is there a way of 
>>>>> placing my
>>>>> own code under the same package hierarchy without all the code 
>>>>> living in
>>>>> the same directory structure.
>>> Yep, looks like that should work, but it doesn't. :-/
>>> Do you have any idea whether other scripts from the same
>>> logical module will still be run in this case?
>> I don't think it will.
> Yeah, I am getting that impression. Gah!
>>> The generated code uses its init script to pull in other code.
>> You could invoke it explicitly via
>> execfile("/path/to/generated/package/")
>> in the static package/
> Hmm, yes, that works. It's not pretty though, it seems to be finding the 
> file relative to the current directory, I suppose writing a bit of code 
> that figures out where this package is located and modifying it won't be 
> too hard.
> And, at the risk of being flamed or sounding like a troll, this seems 
> like something that should be easy to do...other languages manage it 
> quite neatly. Up until this point I was really liking my exposure to 
> Python :-/
> I wonder if there is any more magic that I'm missing, the thing is the 
> pkgutil method looks exactly like what I want, except for not executing 
> the additional files in the added directories.
> Thanks for the help so far Peter, if anyone has a prettier solution then 
> I'm all ears.
> Cheers,
>   n

Maybe I'm missing something obvious, but it sounds like you are 
over-complicating the idea of inheritance.  Do you just want to create a 
subclass of the other class?


More information about the Python-list mailing list