Python Basic Workflow, Shells, Source Code

Python Interpreter

• You don't need to compile Python codes before using them. You execute Python codes using the Interpreter
• Outside of a virtual environment, your interpreter could be called by many names:
◇ python
◇ python2
◇ python3
◇ python3.6
◇ etc.
• Inside a virtual environment, your interpreter will always go by the name python


Python Interactive Shell

• Also known as REPL (read-eval-print-loop)

# Launch python3 shell
## Outside virtual environment

# Inside virtual environment (venv)


Basic REPL/ Source Workflow

• Try stuff in REPL before you commit it to a file

>>> 8*8
>>> print("Hello World")

• Open editor like sublime
• Copy and paste code from REPL to editor

# In the text editor
print("Hello World!")

• Press ctrl-shift-p, type py, select "Set Syntax:Python"
• Save file as “”

# Exit REPL
# or


Running a Source Code File

# cd /filedir/
echo $?
# Output
## 0


REPL vs. Source Code Execution

• The REPL prints ALL return values
• When execute a file, need to explicitly specify to print something out

# REPL reads, evaluates and then print the output
# printing is done automatically
>>> "Hello World"
'Hello World'