Show Menu
Cheatography

python reminders Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Comment

#comment
"­"­" doctring "­"­"

assigning values

foo = val

commun­icating

printting & fromatting
print "my value: %s" % value
asking for value
foo = raw_in­put()
 

Fonction

def foo(args) :
    print "fonction"
    return val

dictio­nnire, liste

list = [a,b,c]
dict = {'x': y, 'a': b}
 

structure

if
for x in y :
while foo :
elif
else

Modules, Classes, and Objects

class Song(object):

    def __init__(self, lyrics):
        self.lyrics = lyrics

    def sing_me_a_song(self):
        for line in self.lyrics:
            print line