KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is it possible to add a base class to an object instance (not a class!) at runtime? Something along the lines of how Object#extend works in Ruby: class Gentleman(object): def introduce_self(self): return "Hello, my name is %s" % self.name class Person(object): def __init__(self, name): self.name = name p = Person("John") # how to implement this method? extend(p, Gentleman) p.introduce_self() # => "Hello, my name is John"
Tags (comma-separated)
Save Edits
Cancel