[docs] [issue19438] Where is NoneType in Python 3?

mpb report at bugs.python.org
Tue Oct 29 21:49:24 CET 2013

mpb added the comment:

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.


Python tracker <report at bugs.python.org>

More information about the docs mailing list