Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90311
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <dreamingforward@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.029 |
| X-Spam-Evidence | '*H*': 0.94; '*S*': 0.00; '(so': 0.07; 'class,': 0.07; 'lines,': 0.07; 'classes.': 0.09; 'latter': 0.09; 'oop': 0.09; 'override': 0.09; 'python': 0.11; 'def': 0.12; 'changes': 0.15; '"""use': 0.16; 'class),': 0.16; 'letting': 0.16; 'refactoring': 0.16; 'sees': 0.16; 'vertex': 0.16; 'wrote:': 0.18; '(in': 0.22; 'issue.': 0.22; 'cheers,': 0.24; "i've": 0.25; 'class.': 0.26; 'pass': 0.26; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'tried': 0.27; '----': 0.29; 'expanding': 0.29; '(like': 0.30; 'expansion': 0.30; 'specified': 0.30; 'message- id:@mail.gmail.com': 0.30; 'along': 0.30; "i'm": 0.30; 'url:wiki': 0.31; 'proposing': 0.31; 'class': 0.32; 'figure': 0.32; 'quite': 0.32; 'everyone': 0.33; '-----': 0.33; 'sense': 0.34; 'skip:_ 10': 0.34; "can't": 0.35; 'classes': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'c++': 0.36; 'object,': 0.36; 'url:org': 0.36; 'example,': 0.37; 'wrong': 0.37; 'clear': 0.37; 'to:addr:python-list': 0.38; 'fact': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'enclosed': 0.60; 'hope': 0.61; 'new': 0.61; 'term': 0.63; 'kind': 0.63; 'more': 0.64; 'different': 0.65; 'within': 0.65; 'between': 0.67; 'specializing': 0.68; 'behaviors': 0.74; 'behavior': 0.77; "'3'": 0.84; 'hammered': 0.84; 'it`s': 0.84; 'messed': 0.84; 'behaviors.': 0.91; 'from.': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=tMrdVYS0laQVqnxudd8AvqGwpnqAgzyZaKbPhc4JVBo=; b=eiDaJdJnnzj0WtY6T0TPqyOtgfa/MS+IEr2qrFlCfYk+F716y9dVD/dxWD2+5VgVn3 5pnFwO9osM6NUr7FlgwlH1qOYcxOXUmntKNqTP0thFh1J8QWXrHzjaumg4MT0+Ufrmrn LyhVNfSc7xcTmmrongabnRA0q1jnnaS93z6syo/mde9dumuhOB6potPBcqc4Xic6NE/m ZsVBu3PaQoPExHacrXkW0cdeWoF5Kks770dL/oPK+zvIoZE6U0et8k6JXNUXIBGrOaQl JR9Ra0S8IooClLT7GG9f5uyIH181Bfi3jHlFoVz1aMbtyXz9c/mYESy14MSaOpVYTpld QcBA== |
| MIME-Version | 1.0 |
| X-Received | by 10.112.132.9 with SMTP id oq9mr6022242lbb.26.1431300366553; Sun, 10 May 2015 16:26:06 -0700 (PDT) |
| In-Reply-To | <CAMjeLr-_jd2wAJJTZRO3+p58hzD+B3UiDyrkhz-Vw-=Lopmrmg@mail.gmail.com> |
| References | <CAMjeLr--RfnfgWc1hdOcHiEBpq3QwC7SZk-m14wM65JtpbgMLQ@mail.gmail.com> <CAMjeLr-_jd2wAJJTZRO3+p58hzD+B3UiDyrkhz-Vw-=Lopmrmg@mail.gmail.com> |
| Date | Sun, 10 May 2015 18:26:06 -0500 |
| Subject | Re: anomaly |
| From | Mark Rosenblitt-Janssen <dreamingforward@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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.325.1431300374.12865.python-list@python.org> (permalink) |
| Lines | 76 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1431300374 news.xs4all.nl 2890 [2001:888:2000:d::a6]:33623 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90311 |
Show key headers only | View raw
Along those lines, it makes no sense for mix-in classes to inherit
from Object at all -- they're neither expanding on object nor
specializing it.
For example, I'm refactoring my python Graph class so that people can
have different Vertex behaviors by using different composition of
mix-in classes. But instead of letting them figure out the object
inheritence order (so there's no conflicts), I'm going to make some
classes that pre-specify the right ordering for different
combiniations of behaviors.
class Vertex(object):
"""Basic Vertex base class, giving a dictionary of edges.""""
class WVertex(Vertex, weighted_mixin): #the weighted_mixin will
override some of the methods in Vertex.
"""Use this when initializing a Graph class for weighted edges."""
class RWVertex(WVertex, reverse_edge_mixin):
"""Use this class for O(1) access to the edges coming into Vertices."""
class Graph(dict):
def __init__(self, init={}, VertexType=Vertex):
"""Creates a Graph with the specified behaviors within VertexType."""
-----
No one has to see the mix-in classes.
I'm inventing a new term for this kind of inheritence: expansion.
I've enclosed one class inside of another, but yet it's not quite
"encapsulation" (in the C++ sense).
Cheers,
Mark J
----
http://wiki.hackerspaces.org/Hacking_with_the_Tao
On 5/10/15, Mark Rosenblitt-Janssen <dreamingforward@gmail.com> wrote:
> Here's where this exploration came from. I've (once again) been
> contemplating the OO nature.
>
> It's clear to me that there needs to be a distinction between
> specialization of an object vs. expansion of an object (a new term I'm
> proposing to the OOP lexicon). The latter *adds* more functionality
> (like what everyone does with the Object class), while the former
> changes the behavior of some class for more specific behavior that was
> not programmed in the original class.
>
> It's a difference between, for example, concrete base types and ABCs.
> Python artificially tried to make int inherit from object, just
> because it can, but this is wrong. It`s messed with the Zen-thing.
> "Purity has hammered practicality [like the fact that we actually have
> to work on concrete types in the CPU] into the ground. " (addition
> mine).
>
> Sorry I can't spend more time clarifying. I hope that there's at
> least one person who sees the issue.
>
> Mark
>
>
>
> On 5/10/15, Mark Rosenblitt-Janssen <dreamingforward@gmail.com> wrote:
>> Here's something that might be wrong in Python (tried on v2.7):
>>
>>>>> class int(str): pass
>>
>>>>> int(3)
>> '3'
>>
>> Mark
>>
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: anomaly Mark Rosenblitt-Janssen <dreamingforward@gmail.com> - 2015-05-10 18:26 -0500
csiph-web