View Single Post
Old Jun 22nd, 2006, 9:26 PM   #1
somehollis
Programmer
 
somehollis's Avatar
 
Join Date: May 2006
Location: Memphis, TN
Posts: 31
Rep Power: 0 somehollis is on a distinguished road
Send a message via AIM to somehollis
Question Why did %S break my if statement?

I was working on an if statement inside a function (see below for code) and made the small typo of %S instead of %s inside of one of my print statements. For some reason this caused the program to exit the function immediately. Can someone explain exactly what that is doing?

I don't know that it matters, but here is the function with the location of the (now former) typo in red. The gratuitous print statments that I used to help me debug are still in there, so you can ignore them.
def remove_person():
    name = input_list()
    if dbase.has_key(name):
    	print 'dbase has %s' % (name)
        print len(dbase[name])
	if not len(dbase[name]) == 0:
            print "%s still has items on loan." % (name)
	    certain = raw_input("Delete anyway? (y/N):")
            if re.match('^[yY][eE]?[sS]?$', certain):
                del dbase[name]
                print 'deleted'
            else:
                print "not deleted"
            print 'delete path NOT taken'
        else:
            print 'delete path taken'
            del dbase[name]
    else:
        print "%s was not found." % (name)
somehollis is offline   Reply With Quote