Re: Disallowing instantiation of super class

2017-02-24 Thread Irv Kalb
> On Feb 24, 2017, at 1:24 AM, Steve D'Aprano > wrote: > > On Fri, 24 Feb 2017 11:19 am, Irv Kalb wrote: > >> Hi, >> >> I have built a set of three classes: >> >> - A super class, let's call it: Base > [...] >> I would like to add is some "insurance" that I (or someone else who uses >> my c

Re: Disallowing instantiation of super class

2017-02-24 Thread Steve D'Aprano
On Sat, 25 Feb 2017 05:40 am, MRAB wrote: >> class Base: >> def __init__(self): >> if type(self) is Base: >> raise TypeError("cannot instantiate Base class") >> >> >> Does that help? >> > D'oh! Never thought of that! :-) > > The OP is using Python 2.7, so you'll need to us

Re: Disallowing instantiation of super class

2017-02-24 Thread MRAB
On 2017-02-24 09:24, Steve D'Aprano wrote: On Fri, 24 Feb 2017 11:19 am, Irv Kalb wrote: Hi, I have built a set of three classes: - A super class, let's call it: Base [...] I would like to add is some "insurance" that I (or someone else who uses my code) never instantiates my Base class,

Re: Disallowing instantiation of super class

2017-02-24 Thread Wolfgang Maier
On 24.02.2017 01:19, Irv Kalb wrote: Hi, I have built a set of three classes: - A super class, let's call it: Base - A class that inherits from Base, let's call that: ClassA - Another class that inherits from Base, let's call that: ClassB ClassA and ClassB have some code in their __init__ m

Re: Disallowing instantiation of super class

2017-02-24 Thread Steve D'Aprano
On Fri, 24 Feb 2017 11:19 am, Irv Kalb wrote: > Hi, > > I have built a set of three classes: > > - A super class, let's call it: Base [...] > I would like to add is some "insurance" that I (or someone else who uses > my code) never instantiates my Base class, It is not intended to be > instant

Re: Disallowing instantiation of super class

2017-02-23 Thread Irv Kalb
> On Feb 23, 2017, at 4:40 PM, MRAB wrote: > > On 2017-02-24 00:19, Irv Kalb wrote: >> Hi, >> >> I have built a set of three classes: >> >> - A super class, let's call it: Base >> >> - A class that inherits from Base, let's call that: ClassA >> >> - Another class that inherits from Base,

Re: Disallowing instantiation of super class

2017-02-23 Thread Peter Otten
Irv Kalb wrote: > Hi, > > I have built a set of three classes: > > - A super class, let's call it: Base > > - A class that inherits from Base, let's call that: ClassA > > - Another class that inherits from Base, let's call that: ClassB > > ClassA and ClassB have some code in their __init__

Re: Disallowing instantiation of super class

2017-02-23 Thread MRAB
On 2017-02-24 00:19, Irv Kalb wrote: Hi, I have built a set of three classes: - A super class, let's call it: Base - A class that inherits from Base, let's call that: ClassA - Another class that inherits from Base, let's call that: ClassB ClassA and ClassB have some code in their __init__

Disallowing instantiation of super class

2017-02-23 Thread Irv Kalb
Hi, I have built a set of three classes: - A super class, let's call it: Base - A class that inherits from Base, let's call that: ClassA - Another class that inherits from Base, let's call that: ClassB ClassA and ClassB have some code in their __init__ methods that set some instance variab