Q:

Python 3.4 script keeps calling same function

I am new to Python and created a script which when called will set my computer to shutdown in x seconds, if called again it will add x seconds to the shutdown.
My problem is that when I check for the arguments the script is called with. If i call the script with '-s' which would shutdown, it first calls the shutdown function and then proceeds to go into the elif statement infinite times until I exit...
if arg == '-s':
    shutdown()
elif arg == '-a':
    abort()
else:
    sys.exit("Error: '%s' isn't a valid argument." % arg)

The full script is here: http://pastebin.com/VnxANLZ5, as the problem might be else where. Other input for making the script better is welcome aswell.

A:

If your script is named shutdown.py, then it's possible that executing os.system("shutdown -s -t %s" % timeToShutdown) or os.system("shutdown -a") will cause the script to execute itself, rather than invoking Windows' built-in shutdown command.
Try renaming your script to something other than shutdown.py.

