0

Here's my sample code:

def Wrapper(SomeClass):
    class WrapperClass(SomeClass):
        pass
    return WrapperClass

class Thing:
    pass

x=Wrapper(Thing)()
print(type(x))

This prints the very ugly (and, more importantly, unclear)

__main__.Wrapper.<locals>.WrapperClass

I know why __main__ is there and I have no problem with it.

However, I'd like to change things so that my print statement gave something that was reflective of the particular class passed into the Wrapper function.

For example, is there a way to change my code so that instead it prints:

__main__.WrapperClass.Thing

Any help would be appreciated.

Daniel Walker
  • 6,380
  • 5
  • 22
  • 45

1 Answers1

0

I ended up being able to solve the problem by using the type constructor.

Daniel Walker
  • 6,380
  • 5
  • 22
  • 45