Theerasak Photha wrote:
> On 10/11/06, Bruno Desthuilliers <[EMAIL PROTECTED]> 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)

Yes, but that's another point. What I was talking about (perhaps not
clearly) is mutable arguments used as returned values, ie:

C-smell:

def my_func(res):
  bar =  foo()
  if bar is None:
    return 1 # error
  else:
    res['bar'] = bar
    res['baaz'] = "blah"
    return 0 # no error

pythonic:

def my_func():
  bar = foo()
  if bar is None:
    raise FooBarError("no bar from foo")
  return dict(bar=bar, baaz='blah')


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to