attribute is accessed from Nonetype
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Aug 3 20:23:26 EDT 2012
On Sat, 04 Aug 2012 08:41:20 +1000, 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.
Shame on you :-P
Ramit Prasad showed exactly how you can see NoneType in action in the
part of the post you snipped from your reply.
py> len(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object of type 'NoneType' has no len()
NoneType *is* a standard type. It's just not bound to a publicly
accessible name in the built-ins. But you can easily get access to the
class using either:
type(None)
None.__class__
or in Python 2.6 at least,
import types
types.NoneType
(although it has been removed from Python 3.2 for some reason).
--
Steven
More information about the Python-list
mailing list