Luis Sousa
llsousa at ualg.pt
Fri Mar 8 11:25:46 EST 2002
> I have two files, one that I used to define a class and other one that > calls the class: > - file that defines the class: pessoalWEB.py > > class MyClass: > def __init__ (self): > self.x = '' > self.y = '' > > - file that uses the class: callClassWEB.py > import pessoalWEB > > def testFunc(): > MyClass = pessoalWEB.MyClass() > saida = MyClass.x > saida = MyClass.y > if saida=='': > saida="NULL" > return saida > > I call this file using > http://machinename/~llsousa/gpessoal/callClassWEB.py/testFunc in my > browser. I already saw what was the problem. The object. was not well initialized. It was MyClass = pessoal.MyClass() instead of MyClass = pessoalWEB.MyClass() But now I notice something strange. When I define saida = MyClass.k it gave no error. Souldn't it gave an error like this: AttributeError: MyClass instance has no attribute 'k' ??? Why it doesn't do that ? Thanks, Luis Sousa
|