-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex37_keywords.py
More file actions
34 lines (34 loc) · 1.92 KB
/
Copy pathex37_keywords.py
File metadata and controls
34 lines (34 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
print("""
KEYWORDS:
------------------------------------------------
and - logical and - ex. True and False == False
as - part of the with-as statement - ex. with X as Y: pass
assert - Assert (ensure) that something is true. - ex. assert False, "Error!"
break - Stop the loop right now - ex. while True: break
class - define a class - ex. class Person(object)
continue - Don't process more of the loop, do it again. - ex. while True: continue
def - Define a function - ex. def X(): pass
del - delete from dictionary - ex. del X[Y]
elif - Else if condition - ex. if: X; elif Y; else: J
else - Else condition - ex. if: X; elif Y; else: J
except - If an exception happens, do this. - ex. except ValueError, e: print(e)
exec - Run a string as Python - ex. exec 'print("hello")'
finally - Exceptions or not, finally do this no matter what - ex. finally: pass
for - Loop over a collection of things - ex. for X in Y: pass
from - Importing specific parts of a module - ex. from x import y
global - Declare you want a global variable - ex. global X
if - If condition - ex. if: X; elif: Y; else: J
import - Import a module into this one to use - ex. import os
in - Part of for-loops. Also a test of X in Y - ex. for X in Y: pass also 1 in [1] == True
is - Like == to test equality - ex. 1 is 1 == True
lambda - Create a short anonymous function - ex. s = lambda y: y ** y; s(3)
not - Logical not. - ex. not True == False
or - Logical or. - ex. True or False == True
pass - This block is empty. - ex. def empty(): pass
print - Print this string. - ex. print('this string')
raise - Raise an exception when things go wrong - ex. raise ValueError("No")
return - Exit the function with a return value. - ex. def X(): return Y
try - Try this block, and if exception, go to except. - ex. try: pass
while - While loop - ex. while X: pass
with - With an expression as a variable do. - ex. with X as Y: pass
yield - Pause hereand return to caller. - ex. def X(): yield Y; X().next()""")