Problem with inspect.getfile

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat May 5 20:42:44 EDT 2007


En Wed, 02 May 2007 11:46:29 -0300, elventear <elventear at gmail.com>  
escribió:

> On May 2, 1:12 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
>> En Wed, 02 May 2007 02:53:55 -0300, elventear <elvent... at gmail.com>
>> escribió:
>>
>> > Found the offending code. I was importing between files that were at
>> > the same level of the hierarchy without using absolute references.
>> > Coded worked fine, but inspect didn't. Was this gaffe on my part? Or
>> > was inspect supposed to handle it?
>>
>> Could you provide an example?
>
> Simple example
>
> My PYTHONPATH points to /python
>
> I have the following:
>
> /python/packages
>     __init.py__
>     /containers
>         __init.py__
>         module1.py
>         module2.py
>
> So basically module2 depends on module1. So within module2.py I was I
> was doing "import module1" instead of import
> "packages.containers.module1". My code ran ok, but the functions in
> the inspect module weren't able to handle it (getfile was the source
> of the problem).

I tried it with Python 2.5 on Windows XP and couldn't make it fail.  
Perhaps it is specific to the Mac, or perhaps it depends on other details  
like __init__.py contents, order of imports, or how specifically you  
import things.

-- 
Gabriel Genellina



More information about the Python-list mailing list