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


Groups > comp.lang.python > #42628

Re: Decorating functions without losing their signatures

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <janpeterr@freenet.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.051
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'arguments': 0.09; 'caller': 0.09; 'python': 0.11; 'jan': 0.12; 'suggest': 0.14; 'attributes,': 0.16; 'attributes.': 0.16; 'metaclass': 0.16; 'subject:their': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'passing': 0.19; 'solution.': 0.20; 'work,': 0.20; 'seems': 0.21; 'creating': 0.23; 'header:User-Agent:1': 0.23; "i've": 0.25; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'bunch': 0.31; 'anyone': 0.31; 'class': 0.32; 'problem': 0.35; 'classes': 0.35; 'something': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'explains': 0.36; 'instances': 0.36; 'returning': 0.36; 'doing': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'example,': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'such': 0.63; 'different': 0.65; 'here': 0.66; 'header :Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'decorate': 0.84; 'url:video': 0.84; 'received:89': 0.85; 'demand': 0.91
Date Wed, 03 Apr 2013 08:06:11 +0300
From Jan Riechers <janpeterr@freenet.de>
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
MIME-Version 1.0
To python-list@python.org
Subject Re: Decorating functions without losing their signatures
References <kjfv4f$4g1$1@dont-email.me>
In-Reply-To <kjfv4f$4g1$1@dont-email.me>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To janpeterr@freenet.de
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.34.1364966074.3114.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364966074 news.xs4all.nl 6904 [2001:888:2000:d::a6]:52738
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42628

Show key headers only | View raw


On 03.04.2013 04:05, Rotwang wrote:
> Hi all,
>
> Here's a Python problem I've come up against and my crappy solution.
> Hopefully someone here can suggest something better. I want to decorate
> a bunch of functions with different signatures; for example, I might
> want to add some keyword-only arguments to all functions that return
> instances of a particular class so that the caller can create instances
> with additional attributes. So I do something like this:
[...]
> It seems to work, but I don't like it. Does anyone know of a better way
> of doing the same thing?

Hi,

I think you might want to check out that Pycon2013 Video about Metaclass 
Prgoramming of David Beazley:
http://www.pyvideo.org/video/1716/python-3-metaprogramming

He explains how to passing attributes, such creating custom classes on 
demand and returning there signatures even when wrapped.

I think that was what you wanted to archive?

Regards
Jan

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


Thread

Decorating functions without losing their signatures Rotwang <sg552@hotmail.co.uk> - 2013-04-03 02:05 +0100
  Re: Decorating functions without losing their signatures Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-03 04:15 +0000
    Re: Decorating functions without losing their signatures Rotwang <sg552@hotmail.co.uk> - 2013-04-04 02:53 +0100
  Re: Decorating functions without losing their signatures Jan Riechers <janpeterr@freenet.de> - 2013-04-03 08:06 +0300
  Re: Decorating functions without losing their signatures Michele Simionato <michele.simionato@gmail.com> - 2013-04-03 18:18 -0700
    Re: Decorating functions without losing their signatures Rotwang <sg552@hotmail.co.uk> - 2013-04-04 03:17 +0100
  Re: Decorating functions without losing their signatures Rotwang <sg552@hotmail.co.uk> - 2013-04-04 02:44 +0100

csiph-web