Jean-Michel Pichavant wrote: > 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
You have to know or verify that .addHandler() appends to the .handlers list, you have to check if or under which conditions h = SomeHandler() root.addHandler(h) assert h is root.handlers[-1] can fail. In short, if I see such a hack my trust in the author of that code is significantly lowered. -- http://mail.python.org/mailman/listinfo/python-list