Carl Banks wrote:
> I could, however, see myself
> using the slightly more complicated descriptor such as this (for a
> wholly different reason, though):
>
> . def call_with_open_file(filename):
> . def descriptor(func):
> . flo = open(filename)
> . try: f(flo)
> . fi
Nick Coghlan wrote:
> Anyway, if others agree that the ability to execute a suite at def
exeuction
> time to preinitialise a function's locals without resorting to
bytecode hacks is
> worth having, finding a decent syntax is the next trick :)
Workarounds:
1. Just use a freaking global, especially
On Fri, 25 Feb 2005 19:34:53 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote:
>Nick Coghlan wrote:
>> Anyway, if others agree that the ability to execute a suite at def
>> exeuction time to preinitialise a function's locals without resorting to
>> bytecode hacks is worth having, finding a decent
Steven Bethard wrote:
Worth looking at is the thread:
http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/58f53fe8bcc49664/
Huh - I thought I put something in the original post saying "without resorting
to bytecode hacks", but I must have deleted it before sending the messag
Nick Coghlan wrote:
Anyway, if others agree that the ability to execute a suite at def
exeuction time to preinitialise a function's locals without resorting to
bytecode hacks is worth having, finding a decent syntax is the next
trick :)
I'm not certain how many use cases really require a full su
Nick Coghlan wrote:
Basically, yeah. Although I later realised I got the name of the feature
I want wrong - default arguments are evaluated when the def statement is
executed, not when the code is compiled. So it's a matter of being able
to execute some code in the functions local namespace at c
Steven Bethard wrote:
So just to clarify, the issue you're trying to address is when you want
early binding like function default arguments get, but you don't want to
declare the names as function arguments?
Basically, yeah. Although I later realised I got the name of the feature I want
wrong -
Nick Coghlan wrote:
Time for another random syntax idea. . .
So, I was tinkering in the interactive interpreter, and came up with the
following one-size-fits-most default argument hack:
[snip]
But consider a syntax like the following:
def f():
use x, y from:
y = x + 1 # [