Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48696
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'none:': 0.07; '__init__': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'attribute,': 0.16; 'message- id:@post.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'repeatedly.': 0.16; 'written,': 0.19; 'header:User-Agent:1': 0.23; 'decorators': 0.24; 'instance,': 0.24; 'header:X-Complaints-To:1': 0.27; 'raise': 0.29; 'specified': 0.30; 'received:132': 0.31; 'writes:': 0.31; 'another': 0.32; 'checking': 0.33; 'subject:from': 0.34; 'too': 0.37; 'easily': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'central': 0.64; 'andrea': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> |
| Subject | Re: decorator to fetch arguments from global objects |
| Date | Wed, 19 Jun 2013 08:03:17 +0000 (UTC) |
| References | <CAF_E5JYg39VdwmLFnyXNOMPRx1UD8ZNGiBRpqgU=A_9rU_ukpw@mail.gmail.com> <kppv2q$shk$1@ger.gmane.org> <CAF_E5JZ3afve8WxOS_vmL_i9vC863uVYc723fV4NPAS=xod7vQ@mail.gmail.com> <loom.20130619T090208-281@post.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | sea.gmane.org |
| User-Agent | Loom/3.14 (http://gmane.org/) |
| X-Loom-IP | 132.230.1.31 (Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0) |
| 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.3574.1371629017.3114.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1371629017 news.xs4all.nl 15925 [2001:888:2000:d::a6]:45345 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:48696 |
Show key headers only | View raw
Wolfgang Maier <wolfgang.maier <at> biologie.uni-freiburg.de> writes:
>
> andrea crotti <andrea.crotti.0 <at> gmail.com> writes:
>
> > 2013/6/18 Terry Reedy <tjreedy <at> udel.edu>
> >
> > Decorators are only worthwhile if used repeatedly. What you specified can
> easily be written, for instance, as
> > def save_doc(db=None):
> > if db is None:
> > db = fetch_from_global()
> > if isinstance(db, dbclass):
> > save_it()
> > else:
> > raise ValueError('need dbobject')
Another suggestion, without knowing too much about your code's architecture:
why not *initialize* your Entity instance with a db_out attribute, so you do
Terry's db checking only in one central place - Entity's __init__ method?
Wolfgang
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: decorator to fetch arguments from global objects Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-06-19 08:03 +0000
csiph-web