what's wrong with "lambda x : print x/60,x%60"
Scott David Daniels
scott.daniels at acm.org
Thu Dec 8 15:04:45 EST 2005
Steve Holden wrote:
> Paul Rubin wrote:
>> .... I think it's a Python weakness that you can't declare a local var like
>> in other languages, to go out of scope at the end of the current block, e.g.:
>>
>> if cond:
>> my x = 7 # make a new scope for x, goes out of scope at end of if
>>
> If this genuinely troubles you then you can always isolate the scope
> with a function, though of course you also no longer have the code
> inline then.
Or, if you must:
def called(function):
function()
return called
then:
@called
def called():
<whatever>
;-)
--
-Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list