How to write Smart Python programs?

Fredrik Lundh fredrik at
Wed Oct 11 11:09:37 CEST 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

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.


More information about the Python-list mailing list