Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #27181

Re: Dynamically determine base classes on instantiation

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <thbach@students.uni-mainz.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; '16,': 0.03; 'raises': 0.07; 'so?': 0.07; 'type,': 0.07; 'python': 0.09; 'wraps': 0.09; 'aug': 0.13; 'belongs': 0.16; 'though)': 0.16; 'wrote:': 0.17; 'thu,': 0.17; '(or': 0.18; 'together.': 0.21; '(on': 0.22; 'subject:skip:i 10': 0.22; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'question': 0.27; '(as': 0.27; 'correct': 0.28; 'actual': 0.28; 'steven': 0.29; 'class': 0.29; 'returned': 0.30; 'function': 0.30; 'stuff': 0.30; 'could': 0.32; '+0200,': 0.33; 'function.': 0.33; 'to:addr:python-list': 0.33; '(with': 0.33; 'another': 0.33; 'so,': 0.35; 'but': 0.36; "wasn't": 0.36; 'method': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'bad': 0.37; 'ok,': 0.37; 'why': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'think': 0.40; 'content-disposition:inline': 0.60; 'first': 0.61; 'thomas': 0.62; 'more': 0.63; 'realized': 0.71; 'saw': 0.75; '"what': 0.84; 'buzz': 0.84; 'received:10.94': 0.84; 'tie': 0.84; '"how': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=uni-mainz.de; i=@uni-mainz.de; q=dns/txt; s=ironport; t=1345136055; x=1376672055; h=date:from:to:subject:message-id:references:mime-version: in-reply-to; bh=MZ0GOQp/Q7CjjILx/OeIlLAUdTmiIYR9B0kgi22TxMI=; b=i9yho6GW2GUXdq7EY5PryyskgmMkIAH/jXAioGm++F76xabfUqKlK5AC 9n3KIYS+VPbd9248ERzfMqulB7eYTVARgpr5o6WjHy5ecHmQaw3wIGM5x CWSpm5AF14UfLoNFqspS4aUXbxQXv2dNMDRL42+/KBByK6Wvh2ut1Cfl5 s=;
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result Ap4EAN4kLVAKXgZY/2dsb2JhbABFtwGEM4IgAQEFOk8IAxgeEBQoIYgkumqLCoM7gjxgA5VOkBOCYQ
Date Thu, 16 Aug 2012 18:54:12 +0200
From Thomas Bach <thbach@students.uni-mainz.de>
To <python-list@python.org>
Subject Re: Dynamically determine base classes on instantiation
References <mailman.3324.1345065532.4697.python-list@python.org> <502c3bc2$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.3358.1345121602.4697.python-list@python.org> <502d0d74$0$6986$e4fe514c@news2.news.xs4all.nl>
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Disposition inline
In-Reply-To <502d0d74$0$6986$e4fe514c@news2.news.xs4all.nl>
User-Agent Mutt/1.5.21 (2010-09-15)
X-Originating-IP [92.225.137.41]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3382.1345136056.4697.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1345136056 news.xs4all.nl 6851 [2001:888:2000:d::a6]:51992
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:27181

Show key headers only | View raw


On Thu, Aug 16, 2012 at 05:10:43PM +0200, Hans Mulder wrote:
> On 16/08/12 14:52:30, Thomas Bach wrote:
> > 
> > So, my question (as far as I can see it, please correct me if I am
> > wrong) is less of the "How do I achieve this?"-kind, but more of the
> > "What is a clean design for this?"-kind. My intuitive thought was that
> > the `merge' function should be a part of the object returned from `F'.
> 
> The misunderstanding is that you feel F should return an object with
> a 'merge' method and a varying abse type, while Steven and others
> think that F should be a function.

OK, then my design wasn't so bad in the first place. :)

I made a class `Model' which wraps the actual type and realized
`merge' and `F' (with a better name, though) as classmethods of
`Model' in order to tie together the stuff that belongs together. By
the way, another need I saw for this design was that

setattr(Model(), 'foo', {'bar': int})

works, whereas 

setattr(dict(), 'foo', {'bar': int}) 

raises an AttributeError (on Python 3.2). Could someone give me the
buzz word (or even an explanation) on why that is so?

     Thomas Bach

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Dynamically determine base classes on instantiation Thomas Bach <thbach@students.uni-mainz.de> - 2012-08-15 23:17 +0200
  Re: Dynamically determine base classes on instantiation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-16 00:16 +0000
    Re: Dynamically determine base classes on instantiation Thomas Bach <thbach@students.uni-mainz.de> - 2012-08-16 14:52 +0200
      Re: Dynamically determine base classes on instantiation Hans Mulder <hansmu@xs4all.nl> - 2012-08-16 17:10 +0200
        Re: Dynamically determine base classes on instantiation Thomas Bach <thbach@students.uni-mainz.de> - 2012-08-16 18:54 +0200
          Re: Dynamically determine base classes on instantiation Richard Thomas <chardster@gmail.com> - 2012-08-16 10:03 -0700
            Re: Dynamically determine base classes on instantiation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-16 17:49 +0000
              Re: Dynamically determine base classes on instantiation Richard Thomas <chardster@gmail.com> - 2012-08-17 04:50 -0700
                Re: Dynamically determine base classes on instantiation Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-17 14:53 -0400
                Re: Dynamically determine base classes on instantiation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-18 01:44 +0000
                Re: Dynamically determine base classes on instantiation Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-18 11:36 +0100
          Re: Dynamically determine base classes on instantiation Richard Thomas <chardster@gmail.com> - 2012-08-16 10:03 -0700
            Re: Dynamically determine base classes on instantiation Thomas Bach <thbach@students.uni-mainz.de> - 2012-08-16 19:27 +0200
      Re: Dynamically determine base classes on instantiation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-16 18:04 +0000
    Re: Dynamically determine base classes on instantiation Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-16 12:29 -0400
    Re: Dynamically determine base classes on instantiation Richard Thomas <chardster@gmail.com> - 2012-08-16 10:09 -0700
      Re: Dynamically determine base classes on instantiation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-16 17:45 +0000
    Re: Dynamically determine base classes on instantiation Thomas Bach <thbach@students.uni-mainz.de> - 2012-08-16 19:18 +0200
      Re: Dynamically determine base classes on instantiation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-16 18:08 +0000

csiph-web