A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2008-June/080309.html below:

[Python-Dev] bug or a feature?

[Python-Dev] bug or a feature? [Python-Dev] bug or a feature?Guido van Rossum guido at python.org
Thu Jun 12 21:46:18 CEST 2008
On Thu, Jun 12, 2008 at 8:24 AM, Armin Rigo <arigo at tunes.org> wrote:
> This discussion is mistakenly focused on locals().  There is a direct
> way to have arbitrary keys in the dict of a type:
>
>>>> MyClass = type('MyClass', (Base,), {42: 64})
>>>> MyClass.__dict__[42]
> 64
>
> There is, however, no way to modify or add non-string keys in the type
> after its creation.  So the question is whether the type() constructor
> is allowed to fail with a TypeError when the initial dict contains
> non-string keys (this is PyPy's current behavior).

The intention was for these dicts to be used as namespaces. I think of
it as follows:

(a) Using non-string keys is a no-no, but the implementation isn't
required to go out of its way to forbid it.

(b) Using non-empty string keys that aren't well-formed identifiers
should be allowed.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
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