0

I have code with many functions and main, when I am trying to run the code it's not working and showing like it run successfully. When I am run the debugger it's show me that it run only on the functions' names. so I am pretty sure the problem it's with the main. how can i solve it?

2
  • Share the logs or code. Commented Feb 13, 2016 at 17:08
  • Please do not edit your question to ask a new question. Instead, simply ask a new question; stackoverflow.com/questions/ask. Commented Feb 17, 2016 at 12:44

1 Answer 1

3

main() is not run implicitly (like in C or Java). In Python you have to explicitly call if you want your code to run.

def main(): some_code() if __name__ == "__main__": main() # actually run main 

Note that main does not have to be named main - it may be arbitrary named function. Moreover, code to run does not even have to be enclosed in any function. Consider file with content like that:

print "abc" 

It'll simply print "abc" on standard output.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.