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?
- Share the logs or code.Mohit Sharma– Mohit Sharma2016-02-13 17:08:13 +00:00Commented 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.Matt– Matt2016-02-17 12:44:49 +00:00Commented Feb 17, 2016 at 12:44
Add a comment |
1 Answer
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.