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?
            Asked
            
        
        
            Active
            
        
            Viewed 81 times
        
    0
            
            
        - 
                    Share the logs or code. – Mohit Sharma Feb 13 '16 at 17:08
- 
                    Please do not edit your question to ask a new question. Instead, simply ask a new question; https://stackoverflow.com/questions/ask. – Matt Feb 17 '16 at 12:44
1 Answers
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.
 
    
    
        Łukasz Rogalski
        
- 22,092
- 8
- 59
- 93
 
    