New submission from mpb:

types.NoneType seems to have disappeared in Python 3.  This is probably 
intentional, but I cannot figure out how to test if a variable is of type 
NoneType in Python 3.

Specifically, I want to write:
assert  type (v) in ( bytes, types.NoneType )

Yes, I could write:
assert  v is None or type (v) is bytes

But the first assert statement is easier to read (IMO).

Here are links to various Python 3 documentation about None:

[1] http://docs.python.org/3/library/stdtypes.html#index-2

[2] http://docs.python.org/3/library/constants.html#None

Link [2] says: "None  The sole value of the type NoneType."  However, NoneType 
is not listed in the Python 3 documentation index.  (As compared with the 
Python 2 index, where NoneType is listed.)

[3] http://docs.python.org/3/library/types.html

If NoneType is gone in Python 3, mention of NoneType should probably be removed 
from link [2].  If NoneType is present in Python 3, the docs (presumably at 
least one of the above links, and hopefully also the index) should tell me how 
to use it.

Here is another link:

[4] http://docs.python.org/3/library/stdtypes.html#bltin-type-objects

"The standard module types defines names for all standard built-in types."  
(Except <class 'NoneType'> ???)

None is a built-in constant.  It has a type.  If None's type is not considered 
to be a "standard built-in type", then IMO this is surprising(!!) and should be 
documented somewhere (for example, at link [4], and possibly elsewhere as well.)

Thanks!

----------
assignee: docs@python
components: Documentation
messages: 201666
nosy: docs@python, mpb
priority: normal
severity: normal
status: open
title: Where is NoneType in Python 3?
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19438>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to