Vocabulary and Symbols Flashcards
(19 cards)
break
while True: break
stop loop right now
class
class Person(object)
define a class
assert
assert False, “Error!”
assert (ensure) that something is true
continue
while True: continue
don’t process more of the loop, do it again
elif
else:
if:
except
except ValueError, e: print e
if an exception happens, do this
exec
exec ‘print “hello” ‘
run as a string in Python
finally
finally: pass
exceptions or not, finally do this no matter what
from
x from y
import a module into this one to use
global
global x
declare that you want a global variable
is
1 is 1 == True
like == to test equality
lambda
s = lambda y: y ** y; s(3)
create a short, anonymous function
not
not True == False
logical not
or
True or False == True
logical or
pass
def empty( ): pass
this block is empty
raise
raise ValueError(“No”)
raise an exception when things go wrong
return
def X( ): return Y
exit the function with a return value
try
try: pass
try this block, and if exception, go to “except”
yield
def X( ): yield Y; X( ).next( )
pause here and return to caller