I set up an environment to write Python 3 Code in my emacs (25.2.2) using python-mode and Elpy on Ubuntu 18.04. Strangely every time I use Python --> Send --> Execute Buffer the program is executed twice. It doesn't matter whether I use the mapped key (F6) or go via the menu.
My code in the relevant parts (it's not doing much so far, I'm mostly trying to learn using emacs as an IDE):
import sys class MyClass: def __init__(self, argv): # Does something... def __call__(self, x): print("Call was called") # But is never called if __name__ == "__main__": print('~~~~Start~~~~') # Does not much more print('~~~~End~~~~')
The result looks like that:
>>> ~~~~Start~~~~ ~~~~End~~~~ >>> ~~~~Start~~~~ ~~~~End~~~~
Disclaimer: I'm very new to emacs, so please excuse if the question doesn't have enough information. I'm willing to provide - just need to know how.
Edit (1): Tried to run a simple Hello world program:
if __name__ == '__main__': print("Hello World")
>>> Hello World >>> Hello World