Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'received:134': 0.05; 'attribute': 0.07; 'think,': 0.07; 'calls.': 0.09; 'filename': 0.09; 'lookup': 0.09; 'def': 0.12; '(other': 0.16; '*should*': 0.16; '__init__,': 0.16; 'illustrate': 0.16; 'itself,': 0.16; 'janssen': 0.16; 'kwargs': 0.16; 'parameter.': 0.16; 'subclass': 0.16; 'subject:object': 0.16; 'file,': 0.19; 'written': 0.21; 'example': 0.22; 'header:User-Agent:1': 0.23; "aren't": 0.24; 'example.': 0.24; "haven't": 0.24; 'header:In- Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'leave': 0.29; 'work.': 0.31; 'getting': 0.31; 'safely': 0.31; 'way?': 0.31; 'class': 0.32; 'supposed': 0.32; 'skip:_ 10': 0.34; 'maybe': 0.34; 'subject:the': 0.34; 'could': 0.34; 'problem': 0.35; 'classes': 0.35; 'something': 0.35; 'but': 0.35; 'crazy': 0.36; 'instances': 0.36; 'done': 0.36; 'method': 0.36; 'possible': 0.36; 'should': 0.36; 'wrong': 0.37; 'work?': 0.38; 'whatever': 0.38; 'to:addr :python-list': 0.38; 'that,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'chain': 0.60; 'most': 0.60; 'new': 0.61; 'simple': 0.61; 'complete': 0.62; 'happen': 0.63; 'yourself': 0.78; 'children.': 0.93 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap8EABnIylGGuA9G/2dsb2JhbABawAaCdIEcgxgBBXgRCyEWDwkDAgECAUUTCAKICrI9iAePURaDTQOXQ4YOizeDEw Date: Wed, 26 Jun 2013 12:56:29 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: What is the semantics meaning of 'object'? References: <15ba0011-bbf1-42f7-b3ea-1c1d4b70e56b@googlegroups.com> <51c66962$0$29999$c3e8da3$5496439d@news.astraweb.com> <20130623133546.GA2308@capricorn> <51c723b4$0$29999$c3e8da3$5496439d@news.astraweb.com> <51C74D6E.6030200@rece.vub.ac.be> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372244196 news.xs4all.nl 16002 [2001:888:2000:d::a6]:57268 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49247 Op 26-06-13 00:27, Mark Janssen schreef: >> The main problem is getting to the top/end of the call chain. Classic >> example is with __init__, but the same problem can also happen with >> other calls. Just a crazy theory, but would it be possible to >> construct a black-holing object that, for any given method name, >> returns a dummy function that ignores its args? (Other forms of >> attribute lookup aren't going to be a problem, I think, so this can be >> just methods/functions.) Then you just subclass from that all the >> time, instead of from object itself, and you should be able to safely >> call super's methods with whatever kwargs you haven't yourself >> processed. Would that work? >> >> Caveat: I have not done much with MI in Python, so my idea may be >> complete balderdash. > Here's how it *should* be made: the most superest, most badassed > object should take care of its children. New instances should > automatically call up the super chain (and not leave it up to the > subclasses), so that the parent classes can take care of the chil'en. > When something goes wrong the parent class has to look in and see > what's wrong. Could you explain why you think it should work this way? Maybe illustrate how this is supposed to work. Let take a very simple example. We have a class that works with a stream (anything with a write method). class Streamer: def __init__(self, strm): ... Now we find that we very often use this class with a file, so we would like to make a subclass that takes a filename as parameter. This we would write somehow like the following class Filer(Streamer): def __init__(self, fn): fl = open(fn, "a+") super.__init__(fl) ... Can you explain how this example should be written en work as you view things?