+ 1

Which lines are executed when a Python file is run?

19th May 2017, 7:15 PM
Michael Baldwin
Michael Baldwin - avatar
1 Antwort
+ 3
Well, the entire contents of the file are read and processed by the interpreter. What gets executed is a bit more up to you. You can have python run like a script, and it will execute commands in the order they are written in, or if you use the if __name__ == "__main__": set up, you can have a more procedural or object oriented structure to the program's flow. It's a very flexible language, so much of the trick is deciding what you want, rather than worrying about being constrained by the language.
20th May 2017, 5:00 AM
Jim
Jim - avatar