Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26458 > unrolled thread

Re: attribute is accessed from Nonetype

Started byChris Angelico <rosuav@gmail.com>
First post2012-08-04 08:41 +1000
Last post2012-08-04 00:23 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: attribute is accessed from Nonetype Chris Angelico <rosuav@gmail.com> - 2012-08-04 08:41 +1000
    Re: attribute is accessed from Nonetype Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-04 00:23 +0000

#26458 — Re: attribute is accessed from Nonetype

FromChris Angelico <rosuav@gmail.com>
Date2012-08-04 08:41 +1000
SubjectRe: attribute is accessed from Nonetype
Message-ID<mailman.2919.1344033688.4697.python-list@python.org>
On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel <d@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

[toc] | [next] | [standalone]


#26463

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2012-08-04 00:23 +0000
Message-ID<501c6b7e$0$29978$c3e8da3$5496439d@news.astraweb.com>
In reply to#26458
On Sat, 04 Aug 2012 08:41:20 +1000, Chris Angelico wrote:

> On Sat, Aug 4, 2012 at 8:20 AM, Dave Angel <d@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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web