Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'true,': 0.05; '(except': 0.07; 'advice.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'api': 0.11; 'subject:Help': 0.11; 'suggest': 0.14; '(it': 0.16; 'api,': 0.16; 'apis.': 0.16; 'better?': 0.16; 'change;': 0.16; 'command-line': 0.16; 'finney': 0.16; 'for,': 0.16; 'low.': 0.16; 'made-up': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sane': 0.16; 'situation.': 0.16; 'subject:class': 0.16; 'subject:which': 0.16; 'module': 0.19; 'trying': 0.19; 'command': 0.22; 'header:User-Agent:1': 0.23; "aren't": 0.24; '(or': 0.24; 'header:X-Complaints-To:1': 0.27; "i'm": 0.30; 'controlled': 0.31; 'writes:': 0.31; 'allows': 0.31; 'class': 0.32; 'interface': 0.32; 'actual': 0.34; 'subject:from': 0.34; "can't": 0.35; 'advice': 0.35; 'but': 0.35; 'height': 0.36; 'received:com.au': 0.36; 'possible': 0.36; 'should': 0.36; 'so,': 0.37; 'being': 0.38; 'expected': 0.38; 'subject:new': 0.38; 'ben': 0.38; 'to:addr :python-list': 0.38; 'expect': 0.39; 'explain': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'units': 0.60; 'effective': 0.61; 'success': 0.61; "you're": 0.61; 'times': 0.62; 'offer': 0.62; 'such': 0.63; 'more': 0.64; 'success,': 0.65; 'assistance': 0.66; 'between': 0.67; 'frequently': 0.68; 'safe': 0.72; 'quality': 0.72; 'as:': 0.81; 'factors,': 0.84; 'one;': 0.84; 'received:125': 0.84; 'robot': 0.91; 'robot,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Help creating new module which inherits existing class from another module. Date: Thu, 20 Feb 2014 13:34:06 +1100 References: <85fvng407b.fsf@benfinney.id.au> <85bny34pql.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: vmx15867.hosting24.com.au X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:tJIOU1y8QV6TO/Rc0wMLkU6Spbw= 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392863659 news.xs4all.nl 2882 [2001:888:2000:d::a6]:39005 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66730 Jonno writes: > Let's say the existing module provides a class RoboCom() which allows > the user to communicate with robots (it doesn't). Well, can you say what it *does* do? These hypotheticals aren't very helpful; I don't know what inferences I'm safe to draw from the made-up situation. What is it you're *actually* trying to allow the user to do? > A command that can be sent to the humanoid robot might look like: > 1. send_cmd("left_leg.knee.raise 1.1") # 1.1 being a height in units of m > A command that can be sent to the canine robot might look like: > 2. send_cmd("tail.wag 3") # where 3 = number of times to wag. So, the robot (except it's not a robot, apparently) is controlled by a textual command API (or is it? is that part true, or just hypothetical?) If you're trying to wrap a command-line based API in an object-oriented API, then you're going to have considerable impedance mismatch between those APIs. Your success will depend on a number of factors, such as: how frequently can the command-line interface be expected to change; how much effective control do you have over the design of the command-line interface; how sane is the command-line interface design; etc. I can't recommend much general advice beyond: don't expect to wrap a command-line interface in an object-oriented interface without greatly distorting one or the other or both. It may be possible to get a modicum of success, but you should not expect it to be satisfactory. Of course, if I knew what you're *actually* trying to program for, I might be able to offer more specific advice. > Does that help explain things better? Not really. It's up to you if you want to be coy about your actual requirements, but the quality of assistance you can expect will be commensurately low. -- \ “Two paradoxes are better than one; they may even suggest a | `\ solution.” —Edward Teller | _o__) | Ben Finney