Reputation:
Using Python 2.7 on Linux
i have two files one is called plot10.py & the other one is called plot10i.py and has def main() in it
with plot10.py being my main file, this is my code:
Upvotes: 0
Views: 70
Reputation: 3865
When you import a module for the first time, it gets executed. So, you need to encapsulate all your execution flow inside functions that will be called from the main program.
In fact, in plot10i.py
your main is as trivial as useless: just prints hello.
You don't need to use if __name__ == '__main__'
if you don't have anything to put in. But if you don't and your project is small, you can use that to include some tests. For example, I would add one to things llike datetime.strptime(x, '%d/%m/%Y %H:%M')
because they are easy to mess up.
Upvotes: 1