Keywords Flashcards
(31 cards)
del
Delete from dictionary.
…del X[Y]
and
Logical and.
…True and False == False
from
Importing specific parts of a module
…from x import Y
not
Logical not
…not True == False
while
while loop, keeps running so long as the test at the top is True
…while X: pass
as
Part of the with-as statement.
…with X as Y: pass
elif
Else if condition.
…if: X; Elif: Y; else: J
global
Declare that you want a global variable
…global X
or
Logical or
..True or False == True
with
With an expression as a variable do.
…with X as Y: pass
assert
Assert (ensure) that something is true.
…assert False, “Error!”
else
Else condition
…if: X; elif: Y; else: J
if
If condition.
…if: X; elif: Y; else: J
pass
This block is empty.
…def empty(): pass
yield
Pause here and return to caller.
…def X(): yield Y; X().next()
break
Stop this loop right now.
…while True: break
except
If an exception happens, do this.
…except ValueError, e: print(e)
import
Import a module into this one to use.
…import os
Print this string.
…print(‘this string’)
class
Define a class.
…class Person(object)
exec
Run a string as Python.
…exec ‘print(“hello”)’
in
Part of for-loops. Also a test of X in Y.
…for X in Y: pass
…1 in [1] == True
raise
Raise an exception when things go wrong.
…raise ValueError(“No”)
continue
Don’t process more of the loop, do it again
…while True: continue