Monday, June 20, 2011

[python] NameError: name 'self' is not defined

Bismillah..

I'm currentlt learning about python..
I take this web as my guide.
http://www.sthurlow.com/python/

then in lesson 8 which i learn about how to create class i got problem...

Traceback (most recent call last):
File "D:/workspace/openerp/sourcecode/phython/lesson8class.py", line 1, in ?
class Shape:
File "D:/workspace/openerp/sourcecode/phython/lesson8class.py", line 17, in Shape
self.y = self.y * scale
NameError: name 'self' is not defined

I gugling... and found these simple answer in this link http://stackoverflow.com/questions/2963654/python-nameerror-self-is-not-defined:

The exception is happening while the class is being defined, which means that your indentation is off. Tabs in Python are equivalent to 8 spaces, so if all the preceding lines are using tabs and your tabstop is set to 4 spaces then the indentation only looks correct.


wuihihi... so make sure you use the correct IDE :D

No comments:

Post a Comment