One of the annoyances you will encounter when interacting with the standard Python interpreter is the need to switch between multiple windows to access Python tools and system command line tools. IPython fills this gap and offers you a syntax for executing shell commands directly from the IPython terminal . We will continue with the terminal commands with you. The command lines I will write now work strictly on a Unix-like system such as Linux or Mac OS X.
While doing research on IPython, I came across the following in an article:
Ipython is a programming tool with the Python kernel but with some advantages over Python. One of the features that make this tool superior is that it has a unique graphical interface and a nice development environment .
We will deal with this later. I’ll be offering a quick introduction here for beginners while working at Shell for now. Let’s continue the subject with our first example.
For example, here we can see the directories and files contained within a user’s system. First of all, our first command that allows us to print text in the terminal will be echo.
✳️ Echo: With this line of code, just like the print function in Python, we print the data to the screen in the terminal. As we can see, it prints the data in quotation marks on the screen.
✳️ Pwd (Print Working Directory):Writes the working directory that the name implies.
✳️ Ls: Lists the contents contained in the working directory.
✳️ Cd: I assume that many of you know this command. It’s a command I use very often. With the cd command, you can navigate between directories. For example, in the following image, we move to the Documents folder.
✳️ Mkdir:Of course, it is possible to create an index when you are in the terminal in the directory we are in! Create a sample folder using the Mkdir command. In addition, I continued the operations by moving to the parent directory. Cd to switch to a parent directory cd .. just use the command.
Quick Introduction to IPython
IPython is a growing project with language-independent components. From IPython 4.0 onwards, the language-independent parts of the project are: laptop format, message protocol, qtconsole, laptop web application, etc. It moved to new projects under the name Jupyter. IPython is focused on interactive Python, Part of which provides a Python kernel for Jupyter. So we’ll try the codes we’ve been working on in shell on Jupyter. For this purpose, we first activate Jupyter Notebook.
After creating any Python 3 notebook in Jupyter, we can try the commands we want. For example, I tried to list my directory, the contents, and print a text on the screen.
Partial List Of Debug Commands
There are many more available commands for interactive debugging than we list here; the table below contains a description of some of the more common and useful ones:
It is possible to use the debug commands you want in IPython lines when you need help. I have given a few commands that we can use in the images below. In this way, we can use the necessary commands.
- Jake VanderPlas, Python Data Science Handbook, Essential Tools For Working with Data.
- IPython, https://mustafaakca.com/ipython/.
- IPython Interactive Computing, Official Website, https://ipython.org.
- Introduction the Shell, https://datacarpentry.org/shell-genomics/01-introduction/index.html.
- Info World, https://www.infoworld.com/article/3193969/10-unix-commands-every-mac-and-linux-user-should-know.html.