![](https://secure.gravatar.com/avatar/a2fc0e250ff81d39df93e62a4ef1ce47.jpg?s=120&d=mm&r=g)
Why would it require a metaclass? Rather than just: ...
Because I want the following to be true: ``` x = Struct[x=int, y=str](...) assert isinstance(x, Struct) assert isinstance(x, Struct[x=int, y=str]) assert not isinstance(x, Struct[x=int, y=int]) ``` On Fri, Aug 14, 2020 at 5:27 PM David Mertz <mertz@gnosis.cx> wrote:
On Fri, Aug 14, 2020, 7:53 PM Caleb Donovick <donovick@cs.stanford.edu> wrote:
I don't see what that can possible get you that `Struct(x=int, y=str)` doesn't.
Using `Struct(x=int, y=str)` requires a metaclass, where `Struct[x=int, y=str]` does not.
Why would it require a metaclass? Rather than just:
class Struct: def __init__(self, **kws): ...
Yes, that won't get you the MRO for T, but neither can __getitem__() on an entirely different object Struct.
A class factory is also an option, of course.