Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: List of Functions Date: Tue, 29 Mar 2016 10:40:18 +1100 Lines: 20 Message-ID: References: <3c44f0f8-d701-463e-bf2c-f5871c51bddf@googlegroups.com> <87bn5z1mkd.fsf@bsb.me.uk> <87mvpjx9kh.fsf@elektro.pacujo.net> <87twjqn2jn.fsf@elektro.pacujo.net> <56f9b5c2$0$1606$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de d133Vp3s0IetqCYiQyLYpAA9jeODya0GHJvuRAs7FcWA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'anyway.': 0.04; 'cc:addr :python-list': 0.09; 'yeah,': 0.09; ':-)': 0.12; '2016': 0.16; 'bases,': 0.16; 'dictionary,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; "{'foo':": 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'example.': 0.18; 'instance,': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'class,': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; "d'aprano": 0.33; 'steven': 0.33; 'subject:List': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'self': 0.38; 'means': 0.39; 'called': 0.40; 'mar': 0.65; 'chrisa': 0.84; 'to:none': 0.91; 'improvement': 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:cc; bh=5kuQwsCWQLJ0ZPL6YHROcdQRtRWdkMi3Bll5/9WCYJA=; b=Ekdh5IXhXSo3B5Y8wyk1drW36c4rXkoNXpCGo9VolmXJ15yXZvjTqau42cxUqhdXYc lORtrzemEEIlwmt7MX5/FOajrEFIzwEH8VWbXmjJ+YEpNOqjr7l0UomIBkFIaIsEuH4w lmE3/Eyk/sNX4BhB30MucerK8r2kplzAKj9/GXY6Qq8Q2zv9JmNWNTKFuIIuXkF1JiwZ GK49txqOBtYfgjJxTxc9WJyqog6RlG9V0YClJjZEfXGGpbcJ2iYKU2rwFvidtUyCPfS/ 78QC2gZd0QF655lJRL/Ebl2qvVP0y9HZjRz+pgx6szCIGrKdroOVft3CcefF6RqwGBzc x46A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=5kuQwsCWQLJ0ZPL6YHROcdQRtRWdkMi3Bll5/9WCYJA=; b=KuGu4GEbny9fvN09zpT9g61aoorf9a3OO0GfHpp4L/mAeIGXsQgv+DTZJrYBTeA9Gd oeDo4NDk2ZuFgAenGg2dawNYaaAXmrNbZpU+vbs78c7ZgnifzYnB17Eupw2Z7hM0V1w9 pJcU2LXqwRf4V7viOWfXTQPCVJ1EeeSLbdN6R5c+M9Knoa5la6AQ+S9+tKcAcS0Ly7j/ ow1nrLKC3yIUKlB8fpefkYGKkUwNzq/iswk50etx1+/nkrXufDwrgtugDib200WWgGIf 4IgT/4vNgOwM9eSmUeb20abj1aTnru/qq+vKiqjiDjFo6lU8t0v4MudbsVJKB0qnf1DM 4RLA== X-Gm-Message-State: AD7BkJIvlUzafxW5kdgf520tQqBQjtxQdcq7vzNd+AMS4P3Qf7BtL5nNWpOgf9Ycie8u+hmTuibGNNb7iP9bQQ== X-Received: by 10.50.138.233 with SMTP id qt9mr12680630igb.13.1459208418905; Mon, 28 Mar 2016 16:40:18 -0700 (PDT) In-Reply-To: <56f9b5c2$0$1606$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105934 On Tue, Mar 29, 2016 at 9:52 AM, Steven D'Aprano wrote: > That would be called "type" :-) > > type(name, bases, namespace) returns a new class: > > > py> C = type("MyClass", (object,), {'foo': 1}) > py> C > > py> C.foo > 1 Yeah, but to do that in a single expression, you need to have all the functions in the dictionary, so it's no improvement over SimpleNamespace. The functions get attached to the class, not the instance, which means they need 'self' - but without assignment, you wouldn't be able to make much use of self anyway. Hence the call for an example. ChrisA