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/2006-July/067460.html below:

[Python-Dev] list.__init__() vs. dict.__init__() behaviour

[Python-Dev] list.__init__() vs. dict.__init__() behaviour [Python-Dev] list.__init__() vs. dict.__init__() behaviourStephen Thorne stephen.thorne at gmail.com
Sat Jul 15 10:44:18 CEST 2006
Hi,

When testing some 'real world' code using pypy, an inconsistancy with
the way __init__ works between lists and dicts.

The assumption was made when implementing __init__ for pypy that
list.__init__ and dict.__init__ would both wipe the contents of the
objects, but it seems that in cpython, this isn't precisely the case.

>>> l = [2,3]
>>> list.__init__(l)
>>> l
[]

>>> d = {2: 3}
>>> dict.__init__(d)
>>> d
{2: 3}

dict.__init__(mydict) does not wipe the keys. list.__init__(mylist)
wipes the lists contents.

https://codespeak.net/issue/pypy-dev/issue240

Is there a good reason for this behaviour? It has broken my code (a
subclass of dict that populates a key before calling the superclasses
constructer, in the twisted codebase).

-- 
Stephen Thorne

"Give me enough bandwidth and a place to sit and I will move the world."
  --Jonathan Lange
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