[Python-ideas] 'Injecting' objects as function-local constants
ethan at stoneleaf.us
Fri Jun 17 19:31:22 CEST 2011
Alex Light wrote:
> On Fri, Jun 17, 2011 at 9:26 AM, Nick Coghlan wrote:
> atdef VAR=EXPR [, VAR=EXPR]*
> Such a statement would readily cover the speed enhancement,
> early-binding and shared state use cases for the default argument hack
> Doing things this way however removes one of the chief benefits of the
> inject statement, the ability to create multiple versions of the same function with
> different sets of shared data.
> Furthermore it gives the added benefit in that you can chose to run
> 'example' so that it uses a true global variable, instead of an injected one.
That answers my question about why you would want to inject into an
already defined function.
More information about the Python-ideas