>
Python Notes : Using the Python Interpreter
Invoking the Interpreter
installed in
C:\Users\n4jvp\AppData\Local\Programs\Python\Python313\Scripts\
launch from command line using py command
to exit enter quit at the prompt
Argument Passing
when known to the interpreter, the script name and additional arguments are turned into a list of strings and assigned to the sys module's' argv variable
access this list by executing import sys
the length of the list is at least one
when no script and no arguments are given sys.argv[0] is an empty string
when the script name is given as '-' (meaning standard input), sys.argv[0] is set to '-'
when -c command is used, sys.argv[0] is set to '-c'
when -m module is used, sys.argv[0] is set to the full name of the located module
options found after -c command or -m module are not consumed by the Python interpreter's option processing but left in sys.argv for the command or module to handle
Interactive Mode
interactive mode - commands are read from the console
>>> - primary prompt
... - secondary prompt, continuation of line
Source Code Encoding
default encoding is UTF-8
to declare a different encoding add special comment as first line in file
# -*- coding: encoding -*-
to declare that Windows-1252 encoding
# -*- coding: cp1252 -*-
previous    index    next