Symbols Flashcards
and
Logical and
Example:
True and False == False
as
Part of the with -as statement.
Example:
with X as Y: pass
assert
Assert (ensure) that something is true
Example:
assert False, “Error!”
break
stop this loop right now
Example:
While True: break
class
Define a class
Example:
class Person(object)
contiunue
Don’t process more of the loop, do it again.
Example:
while True: continue
def
Define a function
Example:
def X(): pass
del
Delete from a dictionary
Example:
del X(Y)
elif
Else if condition
Example:
if: X; elif: Y; else: J
else
Else condition
Example:
if: X; elif:: Y; else: J
except
If an exception happens, do this
Example:
except ValueError, e: print(e)
exec
Run a string as Python
Example:
|exec ‘print(“hello”) ‘
finally
Exceptions or not, finally do this no matter what
Example:
finally: pass
for
loop over a colletion of things
Example:
for X in Y: pass
from
Import specific parts of a module
Example:
from X import Y