Setting an attribute without calling __setattr__()

Arnaud Delobelle arnodel at googlemail.com
Sat Apr 26 12:20:50 EDT 2008


aahz at pythoncraft.com (Aahz) writes:

> In article <m27ielb2i8.fsf at googlemail.com>,
> Arnaud Delobelle  <arnodel at googlemail.com> wrote:
>>Joshua Kugler <jkugler at bigfoot.com> writes:
>>>
>>>             self.me = []
>>>             for v in obj:
>>>                 self.me.append(ObjectProxy(v))
>>
>>Note that is could be spelt:
>>
>>self.me = map(ObjectProxy, v)
                             ^-- I meant obj!
>
> It could also be spelt:
>
> self.me = [ObjectProxy(v) for v in obj]
>
> which is my preferred spelling....

I was waiting patiently for this reply...  And your preferred spelling
is py3k-proof as well, of course.

I don't write map(lambda x: x+1, L) or map(itemgetter('x'), L) but I
like to use it when the first argument is a named function,
e.g. map(str, list_of_ints).

-- 
Arnaud



More information about the Python-list mailing list