AttributeError? Why?

Giorgi Lekishvili gleki at gol.ge
Wed Jun 12 14:32:06 CEST 2002


No, the class ARScenario is in the module ARScenario.py

Another thing is that, importing ARScenario doesn't fail.
>>> import SED
>>> import SED.ARScenario
>>>
====

However, the error maybe as follows:
I was forgetting to import SED in the modules...
Now both
ARScenario(self.xdata)
and
ARScenario.ARScenario(self.xdata)

work.

Thanx for the help.


Eric Brunel wrote:

> 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