Re: Defining class attributes + inheritance

2011-03-08 Thread Santoso Wijaya
Remember the mantra, "Explitic is better than implicit." ;-) ~/santa On Tue, Mar 8, 2011 at 7:15 PM, Martin De Kauwe wrote: > On Mar 9, 12:53 pm, "Rhodri James" > wrote: > > On Wed, 09 Mar 2011 01:00:29 -, Martin De Kauwe > > > wrote: > > > > > class BaseClass(object): > > >def __ini

Re: Defining class attributes + inheritance

2011-03-08 Thread Martin De Kauwe
On Mar 9, 12:53 pm, "Rhodri James" wrote: > On Wed, 09 Mar 2011 01:00:29 -, Martin De Kauwe   > wrote: > > > class BaseClass(object): > >    def __init__(self, a, b, c, d): > >         self.a = a > >         self.b = b > >         self.c = c > >         self.d = d > > > class NewClass(BaseCla

Re: Defining class attributes + inheritance

2011-03-08 Thread Rhodri James
On Wed, 09 Mar 2011 01:00:29 -, Martin De Kauwe wrote: class BaseClass(object): def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d class NewClass(BaseClass): def __init__(self): super(NewClass, self).__init__(new)

Re: Defining class attributes + inheritance

2011-03-08 Thread Santoso Wijaya
Here's how you do inheritance: C:\>python Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class BaseClass(object): ... def __init__(self, a, b, c, d): ... self.a = a ... self.b = b ...

Re: Defining class attributes + inheritance

2011-03-08 Thread Martin De Kauwe
On Mar 9, 11:50 am, "Rhodri James" wrote: > On Wed, 09 Mar 2011 00:29:18 -, Martin De Kauwe   > wrote: > > > > > > > > > On Mar 9, 10:20 am, Ethan Furman wrote: > [snip] > >> Just make sure and call the parent's constructor, either with > > >> class NewClass(BaseClass): > >>      def __init_

Re: Defining class attributes + inheritance

2011-03-08 Thread Rhodri James
On Wed, 09 Mar 2011 00:29:18 -, Martin De Kauwe wrote: On Mar 9, 10:20 am, Ethan Furman wrote: [snip] Just make sure and call the parent's constructor, either with class NewClass(BaseClass): def __init__(self, ): BaseClass.__init__(self, other_params) or class NewC

Re: Defining class attributes + inheritance

2011-03-08 Thread James Mills
On Wed, Mar 9, 2011 at 9:20 AM, Ethan Furman wrote: > Just make sure and call the parent's constructor, either with > > class NewClass(BaseClass): >    def __init__(self, ): >        BaseClass.__init__(self, other_params) > > or > > class NewClass(BaseClass): >    def __init__(self, ): >  

Re: Defining class attributes + inheritance

2011-03-08 Thread Martin De Kauwe
On Mar 9, 10:20 am, Ethan Furman wrote: > Martin De Kauwe wrote: > > Hi, > > > I think this might be obvious? I have a base class which contains X > > objects which other classes inherit e.g. > > > class BaseClass(object): > >     def __init__(self, something, something_else): > >         self.som

Re: Defining class attributes + inheritance

2011-03-08 Thread Ethan Furman
Martin De Kauwe wrote: Hi, I think this might be obvious? I have a base class which contains X objects which other classes inherit e.g. class BaseClass(object): def __init__(self, something, something_else): self.something = something self.something_else = something_else

Re: Defining class attributes + inheritance

2011-03-08 Thread Benjamin Kaplan
On Mar 8, 2011 6:02 PM, "Martin De Kauwe" wrote: > > Hi, > > I think this might be obvious? I have a base class which contains X > objects which other classes inherit e.g. > > class BaseClass(object): >def __init__(self, something, something_else): >self.something = something >