Class problem: loosing my mind

Andrew Bennetts andrew-pythonlist at puzzling.org
Sat Apr 26 22:39:25 EDT 2003


On Sun, Apr 27, 2003 at 02:21:32AM +0000, <stuffduff> wrote:
> I'm 'doing the class pickle thing.'
> 
> I understand that both the module doing the pickling and the module
> doing the unpickling need to reference the same class definition.
> 
> So I go and make a directory under site-packages named gV and in the
> directory i add a file gV.py class gO and a completely empty
> __init__.py
> 
[..]
> 
> At the python prompt I enter import gV, no error.
> 
> Next I try and create an instance:
> 
> x=gV.gO()
> 
> and I get AttributeError: 'gV' module has no attribute 'gO'
> 
> What am I missing here?

Try printing gV.  You'll see that it's the package, i.e. the directory with
the __init__, not the module in it.

You want to do "from gV import gV", then gV.gO() should work.

-Andrew.






More information about the Python-list mailing list