InterviewSolution
| 1. |
What are some different command line options available for using Python interpreter? |
|
Answer» Python interpreter is invoked from command terminal of operating system (Windows or Linux). Two most common WAYS are starting interactive console and running script For interactive console $ python Python 3.6.6 |Anaconda custom (64-bit)| (DEFAULT, Oct 9 2018, 12:34:16) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>>For scripting mode $ python hello.pyIn addition to these common ways, Python command line can have different options. They are listed below: -c cmd : program passed in as string. Interpreter executes the Python code in string which can be one or more statements separated by newlines. $ python -c "print ('hello')" Hello-m mod : run library module as a script. the named module and execute its contents as the __main__ module. The following command creates a new virtual environment $ python -m venv myenv-i: inspect interactively after running script or code with -c option. The interactive prompt APPEARS after the output. This can be useful to inspect global variables or a stack trace when a script raises an exception. $ python -i -c "print ('hello')" hello $ python -i temp.py Hello world >>>Other options are:
|
|