custom-attributes

Can I add custom methods/attributes to built-in Python types?

Can I add custom methods/attributes to built-in Python types? Question: For example—say I want to add a helloWorld() method to Python’s dict type. Can I do this? JavaScript has a prototype object that behaves this way. Maybe it’s bad design and I should subclass the dict object, but then it only works on the subclasses …

Total answers: 8