> 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 <[email protected]> wrote: > > On Fri, Aug 14, 2020, 7:53 PM Caleb Donovick <[email protected]> > 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. > >
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/S5II33XWAICKHHR47OCKVPKURKZRZGTU/ Code of Conduct: http://python.org/psf/codeofconduct/
