attribute is accessed from Nonetype

Dave Angel d at davea.name
Sat Aug 4 01:03:20 CEST 2012


On 08/03/2012 06:41 PM, Chris Angelico wrote:
> On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel <d at davea.name> wrote:
>> I'm sorry, what's not clear?  Nonetype is not the same as NoneType.
>> Python is case sensitive.
> There isn't a NoneType either. I get a NameError.
>
> ChrisA

NoneType isn't in the builtin namespace.  It's in the types module.

    import types
    a = types.Nonetype

It's still special, because None is a singleton.  In any case there are
a number of places where the string "NoneType" is produced,

>>> type(None)
<type 'NoneType'>


>>> None + 3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

>>> None[3]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not subscriptable

etc.

and it's in the docs, at least on page:
    http://docs.python.org/library/constants.html

-- 

DaveA



More information about the Python-list mailing list