Class problem: loosing my mind
stuffduff
stuffduff at cox.net
Sat Apr 26 23:26:09 EDT 2003
Yikes!
It WORKED!
I may still have a job come Monday! ;)
Seems pretty wierd that:
import gV
fails while:
from gV import gV
works.
Thanks a 10E6!
P.S. Any of you 'language lawyers' feel free to enlighten me as to WHY
this works and the other doesn't, I'm all ears!
On Sun, 27 Apr 2003 12:39:25 +1000, Andrew Bennetts
<andrew-pythonlist at puzzling.org> wrote:
>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