(Aug-21-2018, 02:19 PM)ahmed_mokhles Wrote: Well yes I can do that but what I really want is the python code that can produce an EXE, if that is actually possible.Well that what't Pynstaller dos it create a stand alone .exe file.
Py2exe is not updated anymore(only up to Python 3.4),so don't use it.
# coin_toss.py import random import time class Coin: def __init__(self): self.sideup = "Heads" def toss(self): if random.randrange(2) == 0: self.sideup = "Heads" else: self.sideup = "Tails" def toss_result(): my_coin = Coin() print(f"This side is up: {my_coin.sideup}") print("I am tossing the coin...") time.sleep(4) my_coin.toss() print(f"This side is up: {my_coin.sideup}") input('Press Enter to exit') if __name__ == "__main__": toss_result()
# Make from command line cmd(i use cmder) (coin_env) E:\div_code\flatten\coin_env λ pyinstaller --onefile coin_toss.py # cd into dist (coin_env) E:\div_code\flatten\coin_env λ cd dist # One stand alone exe file in dist folder (coin_env) E:\div_code\flatten\coin_env\dist λ ls coin_toss.exe* # Test (coin_env) E:\div_code\flatten\coin_env\dist λ coin_toss.exe This side is up: Heads I am tossing the coin... This side is up: Heads Press Enter to exit