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 423,637 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 3,197 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: Programming Forums

True and False Problem

Join Date: Aug 2007
Posts: 55
Reputation: Seagull One is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Seagull One Seagull One is offline Offline
Junior Poster in Training

Re: True and False Problem

  #4  
May 15th, 2008
Okay, I arranged it into a class, which I think I did right...
ThreeLaws = False

class LawRecite:
def Recite(self):
speaker.Speak(LOR1)
speaker.Speak(LOR2)
speaker.Speak(LOR3)
speaker.Speak(random.choice(LOR4))

LR = LawRecite()

Now if I ask my robot via speech recognition "Do you know the three laws of robotics?" it replies:
speaker.Speak ('Yes, I know them well. Would you like me to recite them for you?')
ThreeLaws = True

That part works fine. However, I've noticed that when I try to print if ThreeLaws is True, like so:

speaker.Speak ('Yes, I know them well. Would you like me to recite them for you?')
ThreeLaws = True
if ThreeLaws == True:
print 'Let's talk about the three laws of robotics'
else:
print 'Not right now'

I get an attribute error that says that 'NoneType' object has no attribute 'tb_lineno'.

Hmm...I think I understand what wooee meant by two blocks of memory with the same name. What I'm trying to do here is change the variable of ThreeLaws from True to False, but because I mention ThreeLaws = .... twice, that's causing it to be destroyed. Am I right? If so, what's the proper way to change a variable's value? Like a switch, I mean?
Reply With Quote  
All times are GMT -4. The time now is 10:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC