Wish: Allow all log Handlers to accept the level argument
Jean-Michel Pichavant
jeanmichel at sequans.com
Thu May 24 05:38:34 EDT 2012
Fayaz Yusuf Khan wrote:
> Jean-Michel Pichavant wrote:
>
>> Meanwhile you can shorten the code this way:
>>
>> root.addHandler(FileHandler('debug.log'))
>> root.handlers[-1].setLevel(DEBUG)
>>
>>
> Eh? Readability was the aim.
>
I fail to see how it's not readable, code is short and no magic is
involved provided you know about slicing list items. Anyway, to answer
your question on why addHandler do not return the handler, I'll quote
Dave Angel from a recent thread about "why s.append(5) does not return s":
"It's simpler than that. Methods/functions either modify the object (or
one of their arguments), or return the results, but generally not both.
So sorted() returns a sorted list without modifying the input. And the
sort() method modifies the list, but does not return it. So you're
right that methods on non-mutables must return the new value, since they
can't modify the object."
JM
More information about the Python-list
mailing list