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/2009-June/090042.html below:

[Python-Dev] Exception for setting attributes of built-in type

[Python-Dev] Exception for setting attributes of built-in type [Python-Dev] Exception for setting attributes of built-in typeMRAB python at mrabarnett.plus.com
Mon Jun 15 00:42:56 CEST 2009
Seo Sanghyeon wrote:
> Exception for setting attributes of built-in type differs between
> CPython and IronPython. This is not purely theoretical, as
> zope.interface tries to set Implements declaration as __implemented__
> attribute of built-in type object, and excepts TypeError.
> 
> Python 2.6.1
>>>> object.flag = True
> TypeError: can't set attributes of built-in/extension type 'object'
> 
> IronPython 2.6
>>>> object.flag = True
> AttributeError: 'object' object has no attribute 'flag'
> 
> I was surprised that CPython raises TypeError. Library Reference seems
> to mention it here:
> 
> exception AttributeError
> Raised when an attribute reference or assignment fails. (When an
> object does not support attribute references or attribute assignments
> at all, TypeError is raised.)
> http://docs.python.org/library/exceptions.html
> 
> What does it mean that "an object does not support attribute
> references or attribute assignments at all"?
> 
Here's my guess:

Some objects have a fixed (and possibly empty) set of attributes.
Attempting to add a new attribute or get a non-existent attribute raises
an AttributeError.

Other objects, such as types (are there any that aren't types?), don't
have attributes at all. Attempting to add or get an attribute raises a
TypeError.
More information about the Python-Dev mailing list

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