Creating a simple Python Interactive Shell

preview_player
Показать описание
In this video, we will try to create a very simple Python Interactive shell in under 13 lines of code.

------------------------------------------------------------

More awesome topics covered here:

------------------------------------------------------------

#python #repl #shell
Рекомендации по теме
Комментарии
Автор

Wait u can make complete terminal in python
import os
while True:
a=input ()
try:
os.system(a)
except Exception as e
print(e)







Thank me later

abduksam
Автор

So your basic shell is working good!
And if you raise error by typing raise and the error the program
will get it and print it as raise command would do!
to make it even better, you can do:
import sys
print("ERROR:", e, file=sys.stderr)

the full form of stderr is standard error and in
some editors and shells it would write text in red color!

psirohi
Автор

But there is a problem: in an actual python shell, when I type something and then use the left and right arrow keys, the cursor will move; however in your shell, when I use arrow keys, say rightarrow, I get ^[[C instead. Is there a way to solve this?

zhiyuanwang
Автор

What Linux distro are you using? I'm getting bored of Ubuntu and Pop OS.

johnwickey
Автор

it can't do any loop work, can you help to solve this problem?

irisariuan
Автор

it works then I try it in another programm and it says this:
except: : is error

aadityanagarajan
Автор

This is awesome.
I want to make an improvement in it: how to write if, else statements and for and while loop.
Can anyone help me to do this.

manbirjudge
welcome to shbcf.ru