473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Is this not infinite?

From a book:

class Derived(Base):
def __init__(self, etc....):
self.__init__(self, etc...)

I don't understand why the 'self' in the call to the Base class
constructor doesn't still refer to the Derived instance. If you say:

x = Derived()

then that triggers the def above. And then that function calls a
constructor, but if it's calling x.__init__, and x is a Derived
instance, it seems like the function keeps calling itself.

Obviously I'm missing a piece of information that would help me to see
why the call gets passed back up to Base...
Mar 7 '06 #1
3 928
John Salerno wrote:
From a book:

class Derived(Base):
def __init__(self, etc....):
self.__init__(self, etc...)
This should be
def __init__(self, etc....):
Base.__init__(self, etc...)

or possibly
def __init__(self, etc....):
super(Derived, self).__init__(etc...)
Obviously I'm missing a piece of information that would help me to see
why the call gets passed back up to Base...


It's a typo in the book.

Kent
Mar 7 '06 #2
Kent Johnson wrote:
This should be
def __init__(self, etc....):
Base.__init__(self, etc...) It's a typo in the book.


Thank goodness! At least I know my mind is heading in the right
direction then... :)
Mar 7 '06 #3
John Salerno wrote:
Kent Johnson wrote:

This should be
def __init__(self, etc....):
Base.__init__(self, etc...)


It's a typo in the book.


Thank goodness! At least I know my mind is heading in the right
direction then... :)


Which book? Many of the authors are here, and I don't recall seeing
that one reported before. These things can sometimes be "patched" in an
errata page for the book, or at least noted here for posterity in case
anyone else tries searching.

-Peter

Mar 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
5
by: mailpitches | last post by:
Hello, Is there any way to kill a Javascript infinite loop in Safari without force-quitting the browser? MP
4
by: LOPEZ GARCIA DE LOMANA, ADRIAN | last post by:
Hi all, I have a question with some code I'm writting: def main(): if option == 1: function_a()
44
by: James Watt | last post by:
can anyone tell me how to do an infinite loop in C/C++, please ? this is not a homework question .
10
by: bhipwell via AccessMonster.com | last post by:
Hello, I am stuck on this one. To illustrate my point, I will use cars as my example. I have a text field for which users can enter in anything they want. This particular field holds the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.