Re: newb __init__ inheritance

2012-03-12 Thread hyperboogie
On Thursday, March 8, 2012 5:25:06 PM UTC+2, hyperboogie wrote: > Hello everyone. > > This is my first post in this group. > I started learning python a week ago from the "dive into python" e- > book and thus far all was clear. > However today while reading chapter 5 about objects and object > ori

Re: newb __init__ inheritance

2012-03-11 Thread Peter Otten
Ian Kelly wrote: > On Sun, Mar 11, 2012 at 5:40 AM, Ian Kelly wrote: >>> 2. Is the mro function available only on python3? >> >> No, but it is available only on new-style classes. If you try it on a >> classic class, you'll get an AttributeError. > > And by the way, you probably shouldn't call

Re: newb __init__ inheritance

2012-03-11 Thread Ian Kelly
On Sun, Mar 11, 2012 at 5:40 AM, Ian Kelly wrote: >> 2. Is the mro function available only on python3? > > No, but it is available only on new-style classes.  If you try it on a > classic class, you'll get an AttributeError. And by the way, you probably shouldn't call the mro method directly. Tha

Re: newb __init__ inheritance

2012-03-11 Thread Ian Kelly
On Sun, Mar 11, 2012 at 4:56 AM, hyperboogie wrote: > 1. What do you mean by "subclassing `object`"? In Python 2 there are two different types of classes: classic classes, which are retained for backward compatibility, and new-style classes, which were introduced in Python 2.2. Classic classes a

Re: newb __init__ inheritance

2012-03-11 Thread Chris Rebert
On Sun, Mar 11, 2012 at 3:56 AM, hyperboogie wrote: > On Sunday, March 11, 2012 12:38:27 PM UTC+2, Chris Rebert wrote: >> On Sun, Mar 11, 2012 at 3:18 AM, hyperboogie wrote: >> >> > thank you everyone... >> > Still things are not working as expected... what am I doing wrong? >> >> > # cat test.p

Re: newb __init__ inheritance

2012-03-11 Thread hyperboogie
On Sunday, March 11, 2012 12:38:27 PM UTC+2, Chris Rebert wrote: > On Sun, Mar 11, 2012 at 3:18 AM, hyperboogie wrote: > > > thank you everyone... > > Still things are not working as expected... what am I doing wrong? > > > # cat test.py > > #!/usr/bin/python > > > > class A(): > > You should be

Re: newb __init__ inheritance

2012-03-11 Thread Chris Rebert
On Sun, Mar 11, 2012 at 3:18 AM, hyperboogie wrote: > thank you everyone... > Still things are not working as expected... what am I doing wrong? > # cat test.py > #!/usr/bin/python > > class A(): You should be subclassing `object`, but that's a minor point which isn't the cause of your problem.

Re: newb __init__ inheritance

2012-03-11 Thread hyperboogie
On Mar 11, 12:47 am, "Colin J. Williams" wrote: > On 10/03/2012 12:58 PM, Colin J. Williams wrote:> On 08/03/2012 10:25 AM, > hyperboogie wrote: > >> Hello everyone. > > [snip] > > main() > > I'm not sure that the class initialization is required. > > > Good luck, > > > Colin W. > > When I wrote

Re: newb __init__ inheritance

2012-03-10 Thread Colin J. Williams
On 10/03/2012 12:58 PM, Colin J. Williams wrote: On 08/03/2012 10:25 AM, hyperboogie wrote: Hello everyone. [snip] main() I'm not sure that the class initialization is required. Good luck, Colin W. When I wrote earlier, I wondered about the need for initialization. With Version 2, both __

Re: newb __init__ inheritance

2012-03-10 Thread Colin J. Williams
On 08/03/2012 10:25 AM, hyperboogie wrote: Hello everyone. This is my first post in this group. I started learning python a week ago from the "dive into python" e- book and thus far all was clear. However today while reading chapter 5 about objects and object orientation I ran into something tha

Re: newb __init__ inheritance

2012-03-08 Thread Ethan Furman
hyperboogie wrote: Hello everyone. This is my first post in this group. I started learning python a week ago from the "dive into python" e- book and thus far all was clear. However today while reading chapter 5 about objects and object orientation I ran into something that confused me. it says h

Re: newb __init__ inheritance

2012-03-08 Thread Peter Otten
Maarten wrote: > Alternatively you can figure out the parent class with a call to super: This is WRONG: > super(self.__class__, self).__init__() You have to name the current class explicitly. Consider: >> class A(object): ... def __init__(self): ... print "in a" ... >>

Re: newb __init__ inheritance

2012-03-08 Thread Maarten
On Thursday, March 8, 2012 4:25:06 PM UTC+1, hyperboogie wrote: > My question is if __init__ in the descendant class overrides __init__ > in the parent class how can I call the parent's __init__ from the > descendant class - I just overrode it didn't I? > > Am I missing something more fundamental

newb __init__ inheritance

2012-03-08 Thread hyperboogie
Hello everyone. This is my first post in this group. I started learning python a week ago from the "dive into python" e- book and thus far all was clear. However today while reading chapter 5 about objects and object orientation I ran into something that confused me. it says here: http://www.divei