How to create a parameterized class with the parameter automatically got

In reply to jianfeng.he:

I believe you many want to use type(tr) instead of tr.get_type(). But you need to show more examples of the flexibility you are looking for.