I have a python program/file that I want to run repeatedly and calculate the averages of some variables over these runs. To do so, I thought it might be convenient to convert this program into a function or a class. One way I can think of is to add a
def Main():
line at the top and indent every line manually within it. Is there an easier way? I am using pydev on eclipse.
Thanks.
Yes you are on the right track.
Add the def Main(): line
Then in pydev select all the other code and then hit tab which will indent all the code
To make the code runnable from the command line ie let it call the Main function you will need to add some code that is executed when the module is loaded. So at the end of the file add
The if command stops the code being run if the file is loaded via an import.