Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...mutable type and want to add some mutable state (maybe you add a default conversion to a string type), it's best to initialize the mutable state in the __init__ method and leave __new__ alone. If you want to change the constructor's signature, you often have to override both __new__ and __init__ to accept the new signature. However, most built-in types ignore the arguments to the method they don't use; in particular, the immutable types (int, long, float, complex, str, unicode, and tup...
...mutable, for example -- and had bugs. Explicitly interning a subclass of string via intern() will raise a TypeError. Internal operations that attempt to intern a string subclass will have no effect. Bug 1003935: xrange() could report bogus OverflowErrors. Documented what xrange() intends, and repaired tests accordingly. Extension modules difflib now supports HTML side-by-side diff. os.urandom has been added for systems that support sources of random data. Patch 1012740: truncate() on a ...
...mutable object, A may be modified in place. Thus, if A is a number or a string, A += B has the same effect as A = A+B (except A is only evaluated once); but if a is a list, A += B has the same effect as A.extend(B)! Classes and built-in object types can override the new operators in order to implement the in-place behavior; the not-in-place behavior is used automatically as a fallback when an object doesn't implement the in-place behavior. For classes, the method name is derived from ...
...mutable built-in types: you can only affect the value of the instance by overloading __new__. You can add mutable attributes, and the subclass instances will have a __dict__ attribute, but you cannot change the "value" (as implemented by the base class) of an immutable subclass instance once it is created. The dictionary constructor now takes an optional argument, a mapping-like object, and initializes the dictionary from its (key, value) pairs. A new built-in type, super, has been ...
...MutableMapping. Created new UserDict class in collections module. This one inherits from and complies with the MutableMapping ABC. Also, moved UserString and UserList to the collections module. The MutableUserString class was removed. Removed UserDict.DictMixin. Replaced all its uses with collections.MutableMapping. Issue #1703: getpass() should flush after writing prompt. Issue #1585: IDLE uses non-existent xrange() function. Issue #1578: Problems in win_getpass. Build Renamed --enable-...
...mutable set type using the keys of a dict to represent the set. There's also a class ImmutableSet which is useful when you need sets of sets or when you need to use sets as dict keys, and a class BaseSet which is the base class of the two. Added random.sample(population,k) for random sampling without replacement. Returns a k length list of unique elements chosen from the population. random.randrange(-sys.maxint-1, sys.maxint) no longer raises OverflowError. That is, it now accepts any combin...
If you didn't find what you need, try your search in the Python language documentation.