A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-April/035218.html below:

[Python-Dev] 2.3b1, and object()

[Python-Dev] 2.3b1, and object()Guido van Rossum guido@python.org
Wed, 30 Apr 2003 09:59:46 -0400
> On an unrelated note, I'm curious, what's the difference between an 
> instance of an object, and an instance of an empty class?  Calling the 
> object builtin returns an <object object at ...>, which I would expect 
> would function the same as a 'class blah(object): pass', but they do 
> not function similarly at all.
> 
>  >>> class A(object): pass
>  >>> a = A()
>  >>> a.i = 5
>  >>> a.i
> 5
>  >>>
> 
>  >>> a = object()
>  >>> a.i = 5
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
> AttributeError: 'object' object has no attribute 'i'

Instances of 'object' don't have an instance dict, so they are
uncapable of having instance variables.  When you use a class
statement, instances of the subclass get an instance dict, unless
__slots__ is used in that class statement.

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4