I\'m very comfortable with .NET objects and its framework for reference vs value types. How do python objects compare to .NET objects? Specifically, I\'m wondering about equalit
__cmp__
or __eq__
method defined object
. This means that doing a > b
is equivalent to doing id(a) > id(b)
.
The is
keyword is also used to see if two variables point to the same object. The ==
operator on the other hand, calls the __cmp__
or __eq__
method of the object it is comparing.
__hash__
method defined for it. All of the basic data types (including strings and tuples) have hash functions defined for them. If there is no __hash__
method defined for a class, that class will inherit it's hash from the object object
.
copy
, copy.deepcopy
, and their respective in class methods __copy__
and __deepcopy__
. Use copy
to copy a single object, deepcopy
to copy a heirarchy of objects. deepcopy
Edits made at the suggestion of agf.