42 # an integer 42.0 # a real number 'wow' or "wow" # a string [1,5,7,9] # a list mylist[0] # the first element of list mylist {1:'one',42:'life'} # a dictionary (maps 1 to 'one', etc.)Assignments
this = that # assign this the value of that ultimateAnswer = 42 # store 42 in variable ultimateAnswer kitten = Kitten("Fluffy") # create a new Kitten, and store it in kitten name = kitten.GetName() # store kitten's current name in name a,b,c = 1,2,3 # multiple assignments at onceFunction Calls
isString('wow') # evaluates to 1 if 'wow' is a string (it is) myObject.DoSomething() # call myObject's DoSomething() methodNote: Class functions (methods) are defined with the first parameter specified, e.g. def GetName(self), but called with the object name before the method name, e.g. self.GetName() .
http://www.strout.net/python/pub/doc/python.htm
Last Modified: 5/08/96 . . . . . . Joe Strout . . . joe@strout.net