- IDE - Integrated Development Environment
- Introspection (understands Python)
- Running, Debugging
- Refactoring
- Mac: PyCharm / Preferences / Project: (name) / Project Interpreter
- Windows/Linux: File / Settings / Project Interpreter
- Same place where we set the interpreter
- At the opening create a new project (directory + Python version)
- File/New Project
- New file
- Open file
- Ctrl-Shift-N
- Run/Run
- Set command line parameters
- Set environment variables
import sys
import datetime
import random
def main():
limit = get_limit()
print(limit)
date = datetime.datetime.now()
rnd = random.randrange(2, 6)
print(rnd)
count(limit)
print("after count")
def get_limit():
limit = 10
if len(sys.argv) == 2:
limit = int(sys.argv[1])
return limit
def count(limit):
for ix in range(limit):
div = ix - 12
show(ix, ix / div)
def show(number, result):
print(number, result)
if __name__ == '__main__':
main()
- Set fixed Breakpoints (click on line next to row-number to have a red circle)
- Run/Debug
- Inspect variables
- Conditional breakpoint
- Step in function
- Step out of function
- Step over function
2 + 3
x = 2
print(x)
def f(x, y):
return x+y
f(4, 5)
- Change variable name (in scope only)
def add(x, y):
z = x + y
return z
def multiply(x, y):
z = x * y
return z
x = 2
y = 3
z = add(x, y)
print(z)
z = multiply(x, y)
print(z)