Re: what exactly does type.__call__ do?

2017-11-02 Thread Jason Maldonis
Thanks for your response. I'm confident that my use case for this metaclass is correct for what I'm trying to do. I've been using them for a few years now, but sparingly because as you said they are almost always unnecessary. I simplified my example significantly for discussion -- I'm not actually

Re: what exactly does type.__call__ do?

2017-11-01 Thread Steve D'Aprano
On Thu, 2 Nov 2017 10:13 am, Jason Maldonis wrote: > Hi everyone, > > I want to use a metaclass to override how class instantiation works. I've > done something analogous to using the Singleton metaclass from the Python3 > Cookbook example. In my opinion, nine times out of ten, using a metaclass

Re: what exactly does type.__call__ do?

2017-11-01 Thread Jason Maldonis
Ok no worries then! Thanks for the tips. I might wait until tomorrow then until someone comes along who deals with metaclasses and alternate class constructors. In case you're curious, I'm doing two things that are relevant here, and I'll link the python3 cookbook examples that are super useful (I

Re: what exactly does type.__call__ do?

2017-11-01 Thread Jason Maldonis
Thanks for the reply. And I think I wasn't clear enough. I was wondering what the metaclass `type`'s `type.__call__` does explicitly. I'm reasonably comfortable writing metaclasses when I need them, and I understand how `.__call__` works for non-metaclass objects. In my first email I gave three po

what exactly does type.__call__ do?

2017-11-01 Thread Jason Maldonis
Hi everyone, I want to use a metaclass to override how class instantiation works. I've done something analogous to using the Singleton metaclass from the Python3 Cookbook example. However, I want to provide a classmethod that allows for "normal" class instantiation that prevents this metaclass fr