Section 1

Preview this deck

class

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (31)

Section 1

(31 cards)

class

Front

Define a class. ex: class Person(object)

Back

with

Front

With an expression as a variable do. ex: with X as Y: pass

Back

assert

Front

Assert (ensure) that something is true. ex: assert False, "Error!"

Back

exec

Front

Run a string as Python. ex: exec 'print "hello"'

Back

global

Front

Declare that you want a global variable. ex: global X

Back

lambda

Front

Create a short anonymous function. ex: s = lambda y: y ** y; s(3)

Back

break

Front

Stop this loop right now. ex: while True: break

Back

yield

Front

Pause here and return to caller. ex: def X(): yield Y; X().next()

Back

return

Front

Exit the function with a return value. ex: def X(): return Y

Back

try

Front

Try this block, and if exception, go to except. ex: try: pass

Back

continue

Front

Don't process more of the loop, do it again. ex: while True: continue

Back

from

Front

Importing specific parts of a module. ex: from x import Y

Back

in

Front

Part of for-loops. Also a test of X in Y. ex: for X in Y: pass also 1 in [1] == True

Back

else

Front

Else condition. ex: if: X; elif: Y; else: J

Back

def

Front

Define a function. ex: def X(): pass

Back

del

Front

Delete from dictionary. ex: del X[Y]

Back

raise

Front

Raise an exception when things go wrong. ex: raise ValueError("No")

Back

for

Front

Loop over a collection of things. ex: for X in Y: pass

Back

if

Front

If condition. ex: if: X; elif: Y; else: J

Back

or

Front

Logical or. ex: True or False == True

Back

import

Front

Import a module into this one to use. ex: import os

Back

is

Front

Like == to test equality. ex: 1 is 1 == True

Back

as

Front

Part of the with-as statement. ex: with X as Y: pass

Back

and

Front

Logical and. ex: True and False == False

Back

while

Front

While loop. ex: while X: pass

Back

elif

Front

Else if condition. ex: if: X; elif: Y; else: J

Back

print

Front

Print this string. ex: print 'this string'

Back

pass

Front

This block is empty. ex: def empty(): pass

Back

not

Front

Logical not. ex: not True == False

Back

except

Front

If an exception happens, do this. ex: except ValueError, e: print e

Back

finally

Front

Exceptions or not, finally do this no matter what. ex: finally: pass

Back