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


Groups > comp.lang.python > #49285

Re: class factory question

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!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 <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.019
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'dynamically': 0.07; 'classes.': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; '*this*': 0.16; 'dict': 0.16; 'globals.': 0.16; 'scope.': 0.16; 'subject:class': 0.16; 'to:addr:web.de': 0.16; 'wrote:': 0.18; '(not': 0.18; 'module': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'message- id:@mail.gmail.com': 0.30; 'that.': 0.31; '>>>>': 0.31; 'skip:m 30': 0.32; 'cases': 0.33; "i'd": 0.34; 'agree': 0.35; 'created': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'within': 0.65; 'skip:m 50': 0.68; 'otten': 0.84; 'do:': 0.91; 'good,': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=cKd3OUoIhDSPHhVEQ7XUTm7WogpMMECilf94kt7hx+M=; b=rv/xRQzr1TKGm6z1V6EQyTNZzm8LHD1MkOK3D0B2Hzl0oOrsS9RgNOmDk2+surgmCW 0VwuQ/kbtEZO4zQYGxhBMw0QoWFGxmGINpCD6OGIzFjTjyLGjpEiPn7RhivpSfwDgSwF MTfFzh+J4xiBI3X/pvIGt7lemPljXP9yyQERomv7km/hDueefjZEAHkrB//8jhd4Fb5a 6Vmdqdk0YBICxyvAboD0zJmfIxQKAjY+Cn44nbXP3SFmqGvcb0+JyW2Hiasj0MmR3f+/ OOygH7k5RodT7GbtU79Z+U7PlLxnNLqWB4IuAPyqfba2JdYfErDCCJ54Xbm4j0xcoAcT XBRA==
X-Received by 10.152.42.171 with SMTP id p11mr2841378lal.79.1372288860284; Wed, 26 Jun 2013 16:21:00 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <kqf21o$b4m$1@ger.gmane.org>
References <138ce5a8-1b4c-49d4-8005-d5f4642dcb97@googlegroups.com> <mailman.3890.1372253972.3114.python-list@python.org> <5d6aa501-58f6-4d8f-8bf5-53d95ff9264e@googlegroups.com> <kqeusq$4h8$1@ger.gmane.org> <CAN1F8qW3bdzA96mCWfzKZOscVSsfL8v49V2mZeTU6Aoz8iWEig@mail.gmail.com> <kqf21o$b4m$1@ger.gmane.org>
From Joshua Landau <joshua.landau.ws@gmail.com>
Date Thu, 27 Jun 2013 00:20:20 +0100
Subject Re: class factory question
To Peter Otten <__peter__@web.de>
Content-Type text/plain; charset=UTF-8
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.3907.1372288868.3114.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372288868 news.xs4all.nl 15864 [2001:888:2000:d::a6]:56003
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49285

Show key headers only | View raw


On 26 June 2013 16:40, Peter Otten <__peter__@web.de> wrote:
> Joshua Landau wrote:
>
>> I would say if a dict isn't good, there are still some cases where you
>> might not want to use globals.
>>
>> I _might_ do:
>
>> # Make a module
>> module_for_little_classes = ModuleType("module_for_little_classes",
>> "All the things")
>> module_for_little_classes.__dict__.update(little_classes)
>
> Hm, from within module_for_little_classes that is globals(). To illustrate:
>
>>>> import __main__ as main
>>>> globals() is main.__dict__
> True

Yes, that's true - but the point wasn't not to use "globals the
function", but not to use *this* global scope.

> Also, I'd spell module.__dict__ vars(module).

Again, good catch. Definitely that.

> That said I agree that it's a good idea to use a dedicated module (not
> necessarily created on the fly) for those dynamically generated classes.

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


Thread

class factory question Tim <jtim.arnold@gmail.com> - 2013-06-26 06:09 -0700
  Re: class factory question Peter Otten <__peter__@web.de> - 2013-06-26 15:39 +0200
    Re: class factory question Tim <jtim.arnold@gmail.com> - 2013-06-26 07:08 -0700
      Re: class factory question Peter Otten <__peter__@web.de> - 2013-06-26 16:46 +0200
        Re: class factory question Tim <jtim.arnold@gmail.com> - 2013-06-26 08:05 -0700
      Re: class factory question Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-26 16:17 +0100
      Re: class factory question Peter Otten <__peter__@web.de> - 2013-06-26 17:40 +0200
      Re: class factory question Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-27 00:20 +0100
  Re: class factory question Fábio Santos <fabiosantosart@gmail.com> - 2013-06-27 00:35 +0100
  Re: class factory question Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-27 14:16 +0100
    Re: class factory question Tim <jtim.arnold@gmail.com> - 2013-06-27 06:37 -0700
      Re: class factory question Dave Angel <davea@davea.name> - 2013-06-27 09:48 -0400
        Re: class factory question Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2013-06-27 17:56 +0200
          Re: class factory question Tim <jtim.arnold@gmail.com> - 2013-06-27 09:40 -0700

csiph-web