[Python-ideas] 'Injecting' objects as function-local constants
Nick Coghlan
ncoghlan at gmail.com
Mon Jun 13 07:07:54 CEST 2011
On Sat, Jun 11, 2011 at 11:30 PM, Jan Kaliszewski <zuo at chopin.edu.pl> wrote:
> 1.
> To add a new keyword, e.g. `inject':
> def do_and_remember(val, verbose=False):
> inject mem = collections.Counter()
> ...
> or maybe:
> def do_and_remember(val, verbose=False):
> inject collections.Counter() as mem
> ...
This particular alternative to the default argument hack has come up
before, as has the "hidden parameters after '**'" approach. (I thought
there was a PEP on this, but I can't find anything other than the
reference in the description of Option 4 in PEP 3103 - however, there
is a thread on the topic that starts as part of the PEP 3103
discussion at http://mail.python.org/pipermail/python-dev/2006-June/066603.html)
Institutional-memory'ly yours,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list