ugh, fine. im coming around to python... string stuffs: "s1 = ' ' Empty string s2 = "spam's" Double quotes block = """ ... """ Triple-quoted blocks s1 + s2 Concatenate, s2 * 3 repeat s2[i], Index, s2[i:j], slice, len(s2) length "a %s parrot" % 'dead' String formatting for x in s2, Iteration, 'm' in s2 membership" string codes: " %s String (or any object's print format) %X Hex integer (uppercase) %c Chapter %e Floating-point format 1a %d Decimal (int) %E Floating-point format 3 %i Integer %f Floating-point format 3 %u Unsigned (int) %g floating-point format 4 %o Octal integer %G Floating-point format 5 %x Hex integer %% Literal % " lists: >>> L = ['spam', 'Spam', 'SPAM!'] >>> L[2] # offsets start at zero 'SPAM!' >>> L[-2] # negative: count from the right 'Spam' >>> L[1:] # slicing fetches sections ['Spam', 'SPAM!'] assignment: " Assignment Creating references curly, moe, larry = 'good', 'bad', 'ugly' Calls Running functions stdout.write("spam, ham, toast\n") Print Printing objects print 'The Killer', joke If/elif/else Selecting actions if "python" in text: print text For/else Sequence iteration for X in mylist: print X While/else General loops while 1: print 'hello' Pass Empty placeholder while 1: pass Break, Continue Loop jumps while 1: if not line: break Try/except/finally Catching exceptions try: action() except: print 'action error' Raise Triggering exception raise endSearch, location Import, From Module access import sys; from sys import stdin Def, Return Building functions def f(a, b, c=1, *d): return a+b+c+d[0] Class Building objects class subclass: staticData = [] Global Namespaces def function(): global X, Y; X = 'new' Del Deleting things del data[k]; del data [i:j]; del obj.attr Exec Running code strings yexec "import" + modName in gdict, ldict Assert Debugging checks assert X > Y " nice switch/case: >>> choice = 'ham' >>> print {'spam': 1.25, # a dictionary-based 'switch' ... 'ham': 1.99, #use has_key() test for default case ... 'eggs': 0.99, ... 'bacon': 1.10}[choice] 1.99 Operation Interpretation import mod Fetch a module as a whole from mod import name Fetch a specific name from a module from mod import* Fetch all top-level names from a module reload(mod) Force a reload of a loaded module's code classes: class FirstClass: # define a class object ... def setdata(self, value): # define class methods ... self.data = value # self is the instance ... def display(self): ... print self.data # self.data: per instance x = FirstClass() x.setdata("King Arthur") x.display() pause @ 11:30am back @ 11:36 exceptions: except: Catch all (other) exception types except name: Catch a specific exception only except name, value: Catch exception and its extra data except (name1, name2): Catch any of the listed exceptions else: Run block if no exceptions raised finally: Always perform block !!!!!!!!!!!!!!!!! "No amount of reading of woodworking magazines is going to turn a novice into a master woodworker. For that to happen, you have to have talent, of course, but also spend years examining furniture, taking furniture apart, building new pieces, learning from your mistakes and others' successes. The same is true in programming. The role of textbooks is to give a bird's eye view of the kinds of problems and appropriate solutions, to show some of the basic tricks of the trade, and, finally, to motivate the frustrated beginner by showing some of the nicer pieces of work others have built. " !!!!!!!!!!!!!!!!!