AttributeError? Why?

Eric Brunel eric.brunel at pragmadev.com
Wed Jun 12 10:15:28 EDT 2002


Giorgi Lekishvili wrote:
> Hi all!
> 
> I have been making a module, which, as I believed, was organized
> correctly. It has __init__.py file, which is empty, and several modules.
> 
> Now, what happens: import goes fine. But when I try to create a class,
>>>> s=SimAn.SimAn([],[],None,0,0)
> Traceback (innermost last):
>   File "<pyshell#18>", line 1, in ?
>     s=SimAn.SimAn([],[],None,0,0)
>   File "D:\Python20\SED\SimAn.py", line 18, in __init__
>     self.Scenario=ARScenario.ARScenario(self.xdata)
> AttributeError: ARScenario
> =====
> Of course, ARScenario is there:
>>>> dir(SimAn)
> ['ARScenario', 'SimAn', '__builtins__', '__doc__', '__file__',
> '__name__', 'copy', 'math']
> =====
> and, of course, the class ARScenario based on the class Scenario, has
> __init__(self,..) method.
> 
> 
> The question: where's my error?

The answer is in the question: why do you try to create an instance of 
ARScenario with:

self.Scenario=ARScenario.ARScenario(self.xdata)

since your ARScenario class is in the SimAn module, as shown by:

>>> dir(SimAn)
['ARScenario', 'SimAn', '__builtins__', '__doc__', '__file__', '__name__', 
'copy', 'math']

If your class ARScenario is in the same module than your SimAn class 
(namely SimAn), just create the ARScenario instance with:

self.Scenario=ARScenario(self.xdata)

It should be enough.

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list