User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 391,601 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,626 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:

True and False Problem

Join Date: Dec 2006
Posts: 384
Reputation: woooee is on a distinguished road 
Rep Power: 2
Solved Threads: 52
woooee woooee is offline Offline
Posting Whiz

Re: True and False Problem

  #5  
May 16th, 2008
If it is a self.variable_name, then it is global throughout the class. I'm too tired to test this snippet so if there are other problems, post back.
class LawRecite:
   def __init__(self):
      self.ThreeLaws = False
      self.Recite()

   def Recite(self):
      ##speaker.Speak(LOR1)
      ##speaker.Speak(LOR2)
      ##speaker.Speak(LOR3)
      ##speaker.Speak(random.choice(LOR4))
      print "ThreeLaws original =", self.ThreeLaws

      self.ThreeLaws=True
      print "ThreeLaws changed =", self.ThreeLaws

      self.ThreeLaws=3
 
LR = LawRecite()
print "after changing to 3 =", LR.ThreeLaws
Last edited by woooee : May 16th, 2008 at 12:06 am.
Reply With Quote  
All times are GMT -4. The time now is 11:52 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC