This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mpb
Recipients christian.heimes, docs@python, mpb
Date 2013-10-29.20:49:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1383079764.13.0.795241439573.issue19438@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-10-29 20:49:24mpbsetrecipients: + mpb, christian.heimes, docs@python
2013-10-29 20:49:24mpbsetmessageid: <1383079764.13.0.795241439573.issue19438@psf.upfronthosting.co.za>
2013-10-29 20:49:24mpblinkissue19438 messages
2013-10-29 20:49:23mpbcreate