How to write Smart Python programs?
Fredrik Lundh
fredrik at pythonware.com
Wed Oct 11 05:09:37 EDT 2006
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>
More information about the Python-list
mailing list