 | Everything in Python is an object (number, function, list, file,
module, class, socket, ...)
|
 | Objects are instances of a class -- lots of classes are defined (float, int, list, file, ...) and the programmer can define new classes
|
 | Variables are names for (or ``pointers'' or ``references'' to) objects:
A = 1 # make an int object with value 1 and name A
A = 'Hi!' # make a str object with value 'Hi!' and name A
print A[1] # A[1] is a str object 'i', print this object
A = [-1,1] # let A refer to a list object with 2 elements
A[-1] = 2 # change the list A refers to in-place
b = A # let name b refer to the same object as A
print b # results in the string '[-1, 2]'
|
 | Functions are either stand-alone or part of classes:
n = len(A) # len(somelist) is a stand-alone function
A.append(4) # append is a list method (function)
|