>>30
In Python's implementation, it means a series of features and things which happen:
1. Values have types, but variables (and object/dictionary/list/set slots) don't. Any variable may carry any type of value and be reset to a value of a different type.
2. Objects are implemented with dictionaries, and may hold any attributes. Objects may be modified, and classes are objects so they can be modified as well (except classes written in C/C++, which unfortunately cannot be edited, though their instances can). You can add or remove attributes (which may be callable attributes, i.e. methods) and you can even change an object's type anytime if you so desire, or change the class attributes (and methods) classes provide to their objects.
3. Everything is an object, and every operation is an object method call, including infix operators which are expanded to method calls (e.g. 3 + 5 is expended to (3).__add__(5)). Python performs no type checking whatsoever, and just attempts to call methods on objects as required. You can do o.f(x, y) to any object o, which will work as long as o has an attribute f which is applicable and supports at least two parameters (actually three, since in Python methods the first parameter is self/this). So if o has an f which supports (x, y) then f is executed, and whatever f does with x and y, Python doesn't care, but if f does x + y, x better be an object which supports __add__ and its __add__ implementation better support whatever y is.
So in essence, you can do anything as long as it works, and you don't ever have to define or require types unless you want to explicitly test for something and throw TypeError if you don't like what your function got. And again, you should
not do something like:
def dup(x):
if type(x) == int:
return x + x
else:
raise TypeError('I wanted an int wah wah wah ;____; (protip: write your own dup for your x, loser)')
but you should rather do:
def dup(x):
try:
return x + x
except:
raise TypeError("Your stupid object doesn't support what I wanted to do, give me something —whatever— that knows how to + itself")