Reputation: 37
I have a program that scans input text looking for a command. A command is in caps and surrounded by <> symbols.
Part of this program includes a function which scans ahead for the next command
def nextCommand(command):
lar = command.find("<LAR>")
#...etc (stripped out variable defs used in statements below)
if lar != -1 and lar > sma or lar > med or lar > bar or lar > fba or lar > fee or lar > lef or lar > rig or lar > cen or lar > end:
print "nextCommand - lar:" + str(lar)
return str("<LAR>")
if sma != -1 and sma > lar or sma > med or sma > bar or sma > fba or sma > fee or sma > lef or sma > rig or sma > cen or sma > end:
print "nextCommandsma:" + str(sma)
return str("<SMA>")
#stripped out more checks
else:
return str("")
This gets called in the main program
print_text = ""
if str(nextCommand(input_string)) != "":
next_command = str(nextCommand(input_string))
print "value recieved from nextCommand() is: " + str(nextCommand)
If I input 123 SMA 456 LAR 789 instead of seeing SM> I am seeing: (took out < symbols as s/o thinks its part of an attack) "value recieved from nextCommand() is:
function nextCommand at <0xb74ce1ec>
What have I done wrong?
Upvotes: 0
Views: 85
Reputation: 60024
You have actually printed the representation of the function. Observe:
nextCommand # This references the function
And:
nextCommand() # This calls the function
I think you meant to put next_command
here instead of nextCommand
print "value recieved from nextCommand() is: " + str(nextCommand)
Should be:
print "value recieved from nextCommand() is: " + next_command
Upvotes: 4