'Templating' over Python types

Viewed 60

Coming from C++, I have a couple of Python types which I want to specialise depending on an enumeration. Rather than storing the enum value as a member on the Python types, I would prefer to 'template' the type over this flag. This would look something like:

template<typename T>
struct base {};

using weak = base<WEAK>;
using strong = base<STRONG>;

Is such a construct possible (or even recommended) in Python?

Edit: So specifically what I'm trying to do is provide a base class which wraps another object. This base class will ensure the wrapped object contains certain attributes. The deriving classes store some additional members. Users will create objects using the derived types

0 Answers
Related