събота, 25 януари 2020 г.

How do I run Python?

    There are a couple of ways to run Python on your PC/laptop and there is no better or worse way to do so - just the one that is most convenient to you. Python itself comes with integrated IDE /Integrated Development Environment/ called IDLE and it is good enough for beginners to learn the basics of this programming language. There are also lots of other very well developed IDEs available online - Spyder /part of Anaconda platform/, Jupyter Notebook /very useful for data science and data science/, PyCharm, Visual Studio Code... And there is no single answer which one is best.

    But how do I work on Python at home? I have some experience with Linux/Unix shell scripting at work and I decided to use the same approach in my side projects. For that purpose I installed Cygwin which is in fact Linux emulator for Windows and comes with already installed Python on it. I edit the code on Notepad++, an excellent free text & code editor supporting multiple programming languages. So, when I need to run my code I open the Cygwin terminal and use the "cd" command /stands for Change Directory/ followed by the path where my scripts are located:

cygwin path


After entering the folder I need to type "python [file name].py" in order to execute the script from the selected file:
cygwin python execute
And that's all. Instead of using "python [file name].py" I often prepare a simple shell script file I call "run" containing this command. In this case I type "sh run" in the Cygwin terminal and the .py file gets executed. Please note that sh run is a shell script command and NOT a Python code.
At the moment there isn't big benefit of using shell script /it will take the same time & space to write "python pd.py" and "sh run"/, however, shell scripting is a great tool for automating stuff and it could be priceless in more complex projects.

Няма коментари:

Публикуване на коментар