I got some similar code to this. Not exacly, but I don't to put to much, but I need that check_type accept r_type parameter as string and check if object type is of value of this string. It is doable?!?!?
I repeat can't do that: n.check_type(r_type=Newer)*, I need take r_type value from configuration file and thats way is a string!
class New(object):
def check_type(self, r_type):
print 'is instance of r_type: ', isinstance(self, r_type)
return isinstance(self, r_type)
class Newer(New):
pass
if __name__ == '__main__':
n = Newer()
n.check_type(r_type='Newer')
Output:
print 'is instance of r_type: ', isinstance(self, r_type)
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types