Movatterモバイル変換
[0]ホーム
[Python-Dev] PEP 409 - final?
Terry Reedytjreedy at udel.edu
Wed Feb 1 21:53:06 CET 2012
On 2/1/2012 3:07 PM, Guido van Rossum wrote:> On Wed, Feb 1, 2012 at 10:48 AM, Ethan Furman<ethan at stoneleaf.us> wrote:>> Guido van Rossum wrote:>>>>>> Hm... Reading this draft, I like the idea of using "raise X from>>> None", but I still have one quibble. It seems the from clause sets>>> __cause__, and __cause__ can indicate three things: (1) print>>> __cause__ (explicitly set), (2) print __context__ (default), (3) print>>> neither (raise X from None). For (1), __cause__ must of course be a>>> traceback object.>>>>>> Actually, for (1) __cause__ is an exception object, not a traceback.>> Ah, sorry. I'm not as detail-oriented as I was. :-)>>>> The PEP currently proposes to use two special>>> values: False for (2), None for (3). To me, this has a pretty strong>>> code smell, and I don't want this pattern to be enshrined in a PEP as>>> an example for all to follow. (And I also don't like "do as I say,>>> don't do as I do." :-)>>>>>> My apologies for my ignorance, but is the code smell because both False and>> None evaluate to bool(False)?>> That's part of it, but the other part is that the type of __context__> is now truly dynamic. I often *think* of variables as having some> static type, e.g. "integer" or "Foo instance", and for most Foo> instances I consider None an acceptable value (since that's how> pointer types work in most static languages). But the type of> __context__ you're proposing is now a union of exception and bool,> except that the bool can only be False.It sounds like you are asking for a special class __NoException__(BaseException) to use as the marker.-- Terry Jan Reedy
More information about the Python-Devmailing list
[8]ページ先頭