Define function to change member data : Class Method : Class PYTHON examples


PYTHON examples » Class » Class Method »

 

Define function to change member data


Define function to change member data
 


class NextClass:                            # define class
    def printer(self, text):                # define method
        self.message = text                 # change instance
        print self.message                  # access instance

x = NextClass()                             # make instance

x.printer('instance call')              # call its method

print x.message                               # instance changed

NextClass.printer(x, 'class call')      # direct class call

print x.message                               # instance changed again


           
         
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Class
» Class Method


Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0