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


Groups > comp.lang.python > #83705

Re: class-based class decorator

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=448906ff1=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.048
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'caller': 0.09; 'decorator': 0.09; 'deprecated': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; "'%s": 0.16; '**kwargs)': 0.16; '**kwargs):': 0.16; '*args': 0.16; 'parameters,': 0.16; 'positional': 0.16; 'subject:based': 0.16; 'subject:class': 0.16; 'solution.': 0.20; 'example': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'simpler': 0.24; 'cc:2**0': 0.24; 'asking': 0.27; 'header:In- Reply-To:1': 0.27; 'especially': 0.30; "i'm": 0.30; 'code': 0.31; 'skip:c 30': 0.32; '-----': 0.33; 'problem': 0.35; 'really': 0.36; 'keyword': 0.36; 'hi,': 0.36; 'thank': 0.38; 'how': 0.40; 'solve': 0.60; 'you.': 0.62; "you've": 0.63; 'hearing': 0.63; 'information': 0.63; 'name': 0.63; 'received:194': 0.64; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'to:addr:yahoo.com': 0.81; 'mean.': 0.91; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="5.07,750,1413237600"; d="scan'208";a="3833147"
Date Tue, 13 Jan 2015 17:37:25 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Albert-Jan Roskam <fomcl@yahoo.com>
In-Reply-To <129524411.66934.1421137532472.JavaMail.yahoo@jws10725.mail.gq1.yahoo.com>
Subject Re: class-based class decorator
MIME-Version 1.0
X-Mailer Zimbra 7.2.7_GA_2942 (ZimbraWebClient - GC37 (Linux)/7.2.7_GA_2942)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc Python <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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17683.1421167053.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1421167053 news.xs4all.nl 2972 [2001:888:2000:d::a6]:58343
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:83705

Show key headers only | View raw


----- Original Message -----
> From: "Albert-Jan Roskam" <fomcl@yahoo.com>
> > From: Jean-Michel Pichavant <jeanmichel@sequans.com>
> > I don't really understand how you successfuly manage positional
> > parameters,
> > since the caller may not name them.
> > I'm asking because if your intend to check only the keyword
> > parameters,
> > there's a much simplier solution.
> > 
> > JM
> 
> 
> Hi,
> 
> Can you give an example of where/how my code would fail? I do not
> intend to use *args and **kwargs, if that is what you mean. I am
> interested in hearing a simpler approach, especially if it would
> also solve the messed-up-signature problem that I mentioned.
> 
> Thank you!
> 
> Albert-Jan
> 

In the example you've given you've deprecated only keyword arguments. So I was wondering...

would the following *untested* code work ? :

def check_deprecated_args(deprecated):
  def decorator(func):
    def inner(*args, **kwargs):
      for p in deprecated:
        if p in kwargs:
          print '%s is deprecated' % p
      return func(*args, **kwargs)
    return inner
  return decorator

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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


Thread

Re: class-based class decorator Jean-Michel Pichavant <jeanmichel@sequans.com> - 2015-01-13 17:37 +0100

csiph-web