views:

89

answers:

2

I'm just starting to learn python... so bear with me please

Why is it giving me a Invalid Syntax error with this block of code

def InvalidArgsSpecified:
    print ("*** Simtho Usage ***\n")
    print ("-i Installs Local App,, include full path")
    print ("-u Uninstalls Installed App,include ID or Name")
    print ("-li Lists all installed Apps and their ID")
    print ("-all Lists All Apps in Repository")
    print ("-di Downloads and Installs App from repository, enter the title or id number")
    print ("-dw Downloads and Installs Single App from a full link")
    print ("-rmall Removes All Packages installed and removes Simtho itself\n")
    print ("*** End of Simtho Usage ***")
    sys.exit()

edit: Now its saying that it's undefined at line 9 Line 9 is

InvalidArgsSpecified()
+6  A: 

The syntax error is in the very first line, where you have:

def InvalidArgsSpecified:

change it to:

def InvalidArgsSpecified():

Those parentheses are mandatory in a def, even when there's nothing between them (just as parentheses are always used to call a function -- empty parentheses, in that case, if you're calling without arguments).

Edit: now the OP's getting an error for trying to call this function in line 9: since this function definition is more than 9 lines, it's probably getting called (from module top-level, rather than from within another function) before it's defined, in which case the simple fix is to call it only after it's defined. If it's anything subtler than that, we'll need to see the code to debug it for you!-)

Alex Martelli
see the above edit please
Indebi
@Indebi, seen, and responded, though questions-with-more-than-a-question-in-them go against the grain and SO's normal behavior! If you have an error, ask a question about it, fix the error accordingly, and thereby reveal a new and completely different error, normal courteous behavior would be to accept the answer that fixed your error, and open a separate question about the new and completely different error.
Alex Martelli
randomgarbagetoletmecommentthanks, it worked
Indebi
+2  A: 

A function without arguments must still include brackets, e.g.:

def InvalidArgsSpecified():
Steve H
see the above edit please
Indebi