Hello this is Juny.
python is interpreter language.
python has interpreter instead of compiler
we can execute python script and any other special command by interpreter.
I will not handle everything of python interpreter.
I will handle most important thing of that.
if you need more information about that, check official python reference homepage.
invoke interpreter
we can invoke python interpreter by launcher.
there is launcher in the location that python is installed in
there are 2 ways to execute launcher.
first one, directly executing python.exe in the installed location.
second one, executing python.exe as command in Windows command prompt.
if you have already set the environment path, you can execute it by "python" keyword.
exit interpreter
if you want to exit interactive interpreter, input the end of file(EOF).
end of file (EOF) is Ctrl+Z in Windows.
interactive mode
if you execute launcher without any command option,
interpreter will be invoked in interactive mode.
interactive interpreter get any command by standard input.
if EOF is input, it exit.
non-interactive mode
we can enter the non-interactive mode by three ways.
- first, with -c command option.
- second, with -m command option.
- third, with script command option.
if non-interactive mode, they are parsed before executed.
we will see only script command in this post.
there are 2 ways to execute python script.
- first, directly double click python script file in Windows explore.
- second, execute launcher with script option in Windows command prompt.
you have to put the full path or relative path of script in command.
python script
interpreter arguments
we can pass the arguments to python interpreter.
they are passed by command options.
python [args]
sys is python module.
argv variable in sys save the arguments that are passed.
for example,
we can do it like "python script a b c d e" in non-interactive interpreter mode.
we can also do it like "python - a b c d" in interactive interpreter mode.
each argument is saved in element of argv.
like "argv[0] = script name(first one), argv[1] = a(second one)"
general options
when you type "--help" as option, you can see the manual of command options.
help function
interpreter has help function.
if you call the function, you can see the manual of lexical keywords.
when you call the function, the prompt is changed from ">>>" to "help>"
you can type any keyword in that.
learn python interpreter argument
Reviewed by Juny
on
7월 03, 2019
Rating:
댓글 없음: