Help with decorators

Mr SZ sk8in_zombi at
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:

    def check_input_sanity(self,rover_input):
        '''Check the input from client'''
        def _check(fn):
            def _inner(rover_input):
                if rover_input[0].upper().replace('L','').replace('R').replace('M') == '' and rover_input[1].upper() in ['N','S','E','W']:
                    print 'Input is sane'    
                return _inner
        return _check            
    def tell_coord_from_path(self):
        '''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 "", line 5, in <module>
    import sys,os,robo
  File "C:\Python25\thought\", line 30, in <module>
    class robo_actions(robo):
  File "C:\Python25\thought\", 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list