Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91158
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <random832@fastmail.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'static': 0.03; 'ideally': 0.04; 'method,': 0.07; 'works.': 0.07; 'imported.': 0.09; 'iterate': 0.09; 'namespace': 0.09; 'overridden': 0.09; 'received:internal': 0.09; 'stack': 0.13; 'explicitly': 0.15; '23,': 0.16; 'c#/.net': 0.16; 'definition.': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'nearest': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:messagingengine.com': 0.16; 'wrote:': 0.16; 'mechanism': 0.18; 'module,': 0.18; '(or': 0.21; 'defined': 0.23; 'matching': 0.23; 'sat,': 0.23; "haven't": 0.24; 'header:In-Reply-To:1': 0.24; 'raise': 0.24; 'written': 0.24; "we'd": 0.24; 'error': 0.27; 'equivalent': 0.27; 'callable': 0.29; 'dictionary': 0.29; 'hacker': 0.29; 'parent': 0.29; 'similar': 0.32; 'class': 0.33; 'raising': 0.33; 'could': 0.35; 'to:addr:python-list': 0.35; 'list': 0.35; "isn't": 0.35; 'but': 0.36; 'list,': 0.36; 'there': 0.36; "let's": 0.36; 'two': 0.37; 'should': 0.37; 'received:10': 0.37; 'subject:: ': 0.37; 'instead': 0.38; 'rather': 0.38; 'received:66': 0.38; 'names': 0.38; 'is,': 0.38; 'method': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'seem': 0.39; 'subject:-': 0.39; 'skip:e 20': 0.39; 'called': 0.40; 'even': 0.61; 'john': 0.61; 'from:no real name:2**0': 0.61; 'header :Message-Id:1': 0.62; 'skip:n 10': 0.63; 'within': 0.64; 'between': 0.65; 'overload': 0.66; 'dr.': 0.69; 'collision': 0.84; 'imagine': 0.96 |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=fd89BQq6f44lNxFp2oFfyC4iIFI=; b=kSWSZd 8dW7JW0Bvm3CV3ZIshs6GqBko1G5vcDv6dCxZ7Drfq/L0Bm+GNT83ydDTEkxW5aZ MVGRTpSuL6WpZICXkUlX0ZlARcx1Kf/DKsi8wIBvAVTsPvcPr8nJNamkykImnyRR jaGjoHLhHbo4FYuPtyTqB6DSCIofCGl5+zJiE= |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=fd89BQq6f44lNxF p2oFfyC4iIFI=; b=BhLf8NmLLmOnciGRHownbyrl9lCYEwriKg5QGgsedtFhAWv Fpnym5KjUxU2YNc8Lrk3GVF8DuGU1A8WOonjH1arIrpdWcbPTfTP2sKEhEkU3ShG p4gGCO/qeUawZMJLAzl3KAtxvAw14YugfPL51bp+Pey1hzBCwaqdIIAraaUc= |
| X-Sasl-Enc | SYOArCWpnS7aqVclN2Y6PaT+eC42o09D4sbMbTJ+TZYw 1432438029 |
| From | random832@fastmail.us |
| To | python-list@python.org |
| MIME-Version | 1.0 |
| Content-Transfer-Encoding | 7bit |
| Content-Type | text/plain |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-75d7cc2d |
| Subject | Re: mix-in classes |
| Date | Sat, 23 May 2015 23:27:09 -0400 |
| In-Reply-To | <CADL-DviUKRgpk-hmK6kqYik0D6bWLXveRLjNWqZPAbximmHhSQ@mail.gmail.com> |
| References | <CADL-DviUKRgpk-hmK6kqYik0D6bWLXveRLjNWqZPAbximmHhSQ@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4.1432438033.5151.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1432438033 news.xs4all.nl 2924 [2001:888:2000:d::a6]:49528 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:91158 |
Show key headers only | View raw
On Sat, May 23, 2015, at 21:53, Dr. John Q. Hacker wrote: > What should happen when there's a name collision on method names between > mix-ins? Since they're mix-ins, it's not presumed that there is any > parent > class to decide. The proper thing would seem to call each method in the > order that they are written within the parent class definition. The way C#/.NET does its nearest equivalent to this is to have this be determined by what "mix-in" is in scope at the call site. That is, for example, the mix-ins for IEnumerable defined in System.Linq.Enumerable is only called if the System.Linq namespace has been imported. IIRC, it's an error for there to be two with identical signatures, which isn't an issue since you can simply explicitly call the method as Enumerable.Whatever(foo) instead of foo.Whatever(). One could imagine a similar mechanism for python... object.__getattr__ could, if nothing is found in the dictionary or by an overridden __getattr__ method, find the call site (construct a stack trace), iterate through an __mixins__ list in the calling module, search each mixin, in order (since it's a list, let's take advantage of it having an order since we haven't got the static type system to do a lot of sophisticated overload resolution), for a matching name. Ideally we'd also have a mechanism for mixin methods to be able to raise NotImplemented (or TypeError?) and have it continue down the list, but any mechanism I can think of for this has the disadvantage that if any of the mixins contains a matching callable it has to return a proxy rather than immediately raising an error, even if none of them actually works.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: mix-in classes random832@fastmail.us - 2015-05-23 23:27 -0400
csiph-web