replacing builtins (WAS: Regular Expressions: large amount of or's)

Steven Bethard steven.bethard at gmail.com
Thu Mar 3 12:52:25 EST 2005


Manlio Perillo wrote:
 > Python allows to subclass builtin classes but the Python Interpreter
 > uses builtin types.
 > As an example keyword arguments are inserted in a dict but I would
 > like to use an user defined SortedDict.
 >
 > There are plans to add such a feature in a future version?

Note that it's polite to start a new thread when you change topic.

That said, I don't expect Python will ever let you replace things like 
this -- it means that libraries would not be able to depend on 
consistent behavior across users.  What would happen if I did something 
like:

class BrokenDict(dict):
     def __getitem__(self, key):
         raise TypeError

and then set Python's dict to this dict instead?  I would break pretty 
much every function that takes a **kwargs argument.

STeVe



More information about the Python-list mailing list