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


Groups > comp.lang.python > #42628

Re: Decorating functions without losing their signatures

Date 2013-04-03 08:06 +0300
From Jan Riechers <janpeterr@freenet.de>
Subject Re: Decorating functions without losing their signatures
References <kjfv4f$4g1$1@dont-email.me>
Newsgroups comp.lang.python
Message-ID <mailman.34.1364966074.3114.python-list@python.org> (permalink)

Show all headers | 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