Is it possible to run python script as if it's a command line interpreter, Example :
from sys import argv
argv=argv[1:]
str=''.join(argv)
import os
def ls():
x=os.listdir(os.getcwd())
for file in x:
print(file)
if str =='ls':
ls()
in this case I used argv to pass arguments, but can I want the code to behave like a command line interpreter and call my functions example:
myscript> ls file.py myscript>
Note :Sorry if i didn't explain my idea clearly, English is not my native language.
Update : some people said my question is duplicated and the same question of this but i repeat , I want to make "interactive shell" not "How to execute Python scripts in Windows"