Keywords Flashcards
and
Logical and.
True and False == False
as
Part of the with-as statement.
with X as Y: pass
assert
Assert (ensure) that something is true.
assert False, “Error!”
break
Stop this loop right now.
while True: break
class
Define a class.
class Person(object)
continue
Don’t process more of the loop, do it again.
while True: continue
def
Define a function.
def X(): pass
del
Delete from dictionary.
del X[Y]
except
If an exception happens, do this.
except ValueError, e: print e
exec
Run a string as Python.
exec ‘print “hello”’
finally
Exceptions or not, finally do this no matter what.
finally: pass
from
Importing specific parts of a module.
from x import Y
global
Declare that you want a global variable.
global X
in
Part of for-loops. Also a test of X in Y.
for X in Y: pass also 1 in [1] == True
is
Like == to test equality.
1 is 1 == True