I want a class that will determine its base class by the argument passed
in. What I am about to write _does_not_work_ , but it shows what I am
trying to do.
class ABC(some_super) :
def __init__(self,s ome_super):
some_super.__in it__(self)
if some_super == list:
self.append('AB C')
elif some_super == dict:
self['ABC'] = None
Then, the user can call this function:
['ABC']
{'ABC': None}
Clearly, this is a bad example, but the central idea is what I am trying
to do. ABC is a particular example which can be represented in various
forms. I want an ABC class that will create the example in the form
specified by the user.
So how can I achieve this? Thanks.
in. What I am about to write _does_not_work_ , but it shows what I am
trying to do.
class ABC(some_super) :
def __init__(self,s ome_super):
some_super.__in it__(self)
if some_super == list:
self.append('AB C')
elif some_super == dict:
self['ABC'] = None
Then, the user can call this function:
>>example = ABC(list)
>>print example
>>print example
>>example = ABC(dict)
>>print example
>>print example
Clearly, this is a bad example, but the central idea is what I am trying
to do. ABC is a particular example which can be represented in various
forms. I want an ABC class that will create the example in the form
specified by the user.
So how can I achieve this? Thanks.
Comment