[Tutor] How to set variables inside a class()

Reuben reuben.dlink at gmail.com
Tue Nov 26 08:30:18 CET 2013


Hi,

Following is my code:
#############################################
class Animal():

      flag = True
      print flag

      def __init__(self,name):
           self.name = name
           print self.name

      def walk(self):
          print "I am walking"


if __name__ == '__main__':
     test = Animal('boxer')
     test.flag = False
     test.walk()

#############################################




My question is:
____________

1)Inside the Animal class(), How can I set the variable 'flag' to FALSE?


Regards,
Reuben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131126/f4202d34/attachment-0001.html>


More information about the Tutor mailing list