By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,143 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,143 IT Pros & Developers. It's quick & easy.

"Learning Python" 2nd ed. p479 error?

P: n/a
Hello all.

On page 479, the 2nd edition of the "Learning Python" book, this code
appears

class Derived(Base):
def __init__(self, arg, *args, **kw):
self.__init__(self, *args, **kw)

Surely self.__init__ should be

Base.__init__

Everything else in the book has been crystal clear. Up to page 479!
It doesn't appear in the errata. What am I misunderstanding?
Regards,

Abraham

May 26 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Ab********************@yahoo.com wrote:
On page 479, the 2nd edition of the "Learning Python" book, this code
appears

class Derived(Base):
def __init__(self, arg, *args, **kw):
self.__init__(self, *args, **kw)

Surely self.__init__ should be

Base.__init__
I don't have a copy within reach, but from what you say, it sure looks
like a typo.
It doesn't appear in the errata. What am I misunderstanding?


nothing, except perhaps what's the best place to report errors in
O'Reilly books (I'm quite sure they don't read this newsgroup ;-)

there's a "view/submit errata" link on this page:

http://www.oreilly.com/catalog/lpython2/

</F>

May 26 '06 #2

P: n/a
Ab********************@yahoo.com wrote:
Hello all.

On page 479, the 2nd edition of the "Learning Python" book, this code
appears

class Derived(Base):
def __init__(self, arg, *args, **kw):
self.__init__(self, *args, **kw)

Surely self.__init__ should be

Base.__init__

Everything else in the book has been crystal clear. Up to page 479!
It doesn't appear in the errata. What am I misunderstanding?


Seems to be a typo:

Python 2.4.2 (#1, Jan 23 2006, 21:24:54)
[GCC 3.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
class A(object): .... def __init__ (self):
.... print 'Constructing A'
.... class B(A): .... def __init__ (self):
.... self.__init__ (self)
.... B() Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in __init__
TypeError: __init__() takes exactly 1 argument (2 given) class C(A): .... def __init__ (self):
.... A.__init__ (self)
.... C()

Constructing A
<__main__.C object at 0x402cf5ac>


Mel.
May 26 '06 #3

P: n/a
Looks like an error. I didn't see it the errata:

http://www.oreilly.com/catalog/lpython2/errata/

May 26 '06 #4

P: n/a
Thanks for your help, guys. I'm convinced it is a bug, not a
misunderstanding. I submitted it to the errata page at O'Reilly.
Regards,

Abraham

May 27 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.