0

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?

2
  • 2
    Why str("<SMA>")? "<SMA>" is a string already. Commented Aug 21, 2013 at 10:29
  • It wasnt originally but was sniffing around wrong trees when trying to debug it Commented Aug 21, 2013 at 10:37

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.