Help with decorators
sk8in_zombi at yahoo.com.au
Fri Jul 18 16:27:10 CEST 2008
I'm using decos for the first time.I want to check the input and then call a function in a class.
I'm pasting the code:
'''Check the input from client'''
if rover_input.upper().replace('L','').replace('R').replace('M') == '' and rover_input.upper() in ['N','S','E','W']:
print 'Input is sane'
'''Gives the final co-ordinate and the direction untill it falls off/reaches.'''
pdir = self.origorient #Present direction
here the vars : self.origorient,self.direction_str,self.init_loc are the ones I would like to check for sanity.
But I get an error:
Traceback (most recent call last):
File "tw.py", line 5, in <module>
File "C:\Python25\thought\robo.py", line 30, in <module>
File "C:\Python25\thought\robo.py", line 58, in robo_actions
NameError: name 'self' is not defined
Why is this so? aren't they to be referred to by self with in a class as they are attributes of the object ?
" life isn't heavy enough,it flies away and floats far above action"
Start at the new Yahoo!7 for a better online experience. www.yahoo7.com.au
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list