Re: How to write Smart Python programs?
- From: Fredrik Lundh <fredrik@xxxxxxxxxxxxxx>
- Date: Wed, 11 Oct 2006 11:09:37 +0200
Theerasak Photha wrote:
>> 2/ functions that returns a status code and modify their arguments.
Argument modification for lists with one item is *sometimes* used to
emulate full lexical closure. (or at least that's what the folks on
freenode #python told me)
sounds like they (or you) are confusing "arguments" with "free variables", though. here's an example of the latter:
def outer():
var = [value]
def inner():
var[0] = new value
inner()
here's an example of the former:
def func(var):
var[0] = new value
return something else
myvar = [value]
res = func(myvar)
the second example feels rather contrived; if you need to return multiple values, just return them.
</F>
.
- References:
- How to write Smart Python programs?
- From: Raj
- Re: How to write Smart Python programs?
- From: Bruno Desthuilliers
- How to write Smart Python programs?
- Prev by Date: Re: sufficiently pythonic code for testing type of function
- Next by Date: Re: Converting MSWord Docs to PDF
- Previous by thread: Re: How to write Smart Python programs?
- Next by thread: Re: How to write Smart Python programs?
- Index(es):
Relevant Pages
|