Message201670
Of your 4 suggestions, I mentioned #3 and #4 in my post. They are less readable, IMO.
1 and 2 are nicer, but both have an "extra" set of nested parenthesis.
While I appreciate the suggestions, I submitted this as a documentation bug, because I think I should be able to find these suggestions somewhere in the Python 3 documentation, at one (or more) of the links I included in my bug report. Also, the Python 3 documentation does mention NoneType, and if NoneType is not part of Python 3, I claim this is an error in the documentation.
And then, there is my personal favorite work-around:
NoneType = type (None) # only needed once
assert type (v) in ( bytes, NoneType )
Or (perhaps more confusingly, LOL!):
none = type (None)
assert type (v) in ( bytes, none )
isinstance is more confusing because it takes two arguments. Whenever I use it I have to think, "isinstance" vs "instanceof", which is Python, which is Java? (And I haven't used Java seriously in years!) And then I have to think about the order of the arguments (v, cls) vs (cls, v). type is just simpler than isinstance. |
|
Date |
User |
Action |
Args |
2013-10-29 20:49:24 | mpb | set | recipients:
+ mpb, christian.heimes, docs@python |
2013-10-29 20:49:24 | mpb | set | messageid: <1383079764.13.0.795241439573.issue19438@psf.upfronthosting.co.za> |
2013-10-29 20:49:24 | mpb | link | issue19438 messages |
2013-10-29 20:49:23 | mpb | create | |
|