summaryrefslogtreecommitdiffstats
path: root/Lib/UserDict.py
Commit message (Collapse)AuthorAgeFilesLines
* Raise statement normalization in Lib/.Collin Winter2007-08-301-3/+3
|
* PEP 3114: rename .next() to .__next__() and add next() builtin.Georg Brandl2007-04-211-1/+1
|
* Some more test now pass.Guido van Rossum2007-02-151-1/+1
|
* Fix the damage to UserDict and its tests.Guido van Rossum2007-02-151-14/+13
| | | | | | | Clearly this is not the right way to fix this; UserDict and MixinDict ought to be redesigned with the new dict API in mind. But I'm not claiming to be in charge of library redesign, I only want zero failing tests.
* - PEP 3106: dict.iterkeys(), .iteritems(), .itervalues() are now gone;Guido van Rossum2007-02-111-12/+15
| | | | | | | | | | and .keys(), .items(), .values() return dict views. The dict views aren't fully functional yet; in particular, they can't be compared to sets yet. but they are useful as "iterator wells". There are still 27 failing unit tests; I expect that many of these have fairly trivial fixes, but there are so many, I could use help.
* Restructure comparison dramatically. There is no longer a defaultGuido van Rossum2006-08-241-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *ordering* between objects; there is only a default equality test (defined by an object being equal to itself only). Read the comment in object.c. The current implementation never uses a three-way comparison to compute a rich comparison, but it does use a rich comparison to compute a three-way comparison. I'm not quite done ripping out all the calls to PyObject_Compare/Cmp, or replacing tp_compare implementations with tp_richcompare implementations; but much of that has happened (to make most unit tests pass). The following tests still fail, because I need help deciding or understanding: test_codeop -- depends on comparing code objects test_datetime -- need Tim Peters' opinion test_marshal -- depends on comparing code objects test_mutants -- need help understanding it The problem with test_codeop and test_marshal is this: these tests compare two different code objects and expect them to be equal. Is that still a feature we'd like to support? I've temporarily removed the comparison and hash code from code objects, so they use the default (equality by pointer only) comparison. For the other two tests, run them to see for yourself. (There may be more failing test with "-u all".) A general problem with getting lots of these tests to pass is the reality that for object types that have a natural total ordering, implementing __cmp__ is much more convenient than implementing __eq__, __ne__, __lt__, and so on. Should we go back to allowing __cmp__ to provide a total ordering? Should we provide some other way to implement rich comparison with a single method override? Alex proposed a __key__() method; I've considered a __richcmp__() method. Or perhaps __cmp__() just shouldn't be killed off...
* Get rid of dict.has_key(). Boy this has a lot of repercussions!Guido van Rossum2006-08-181-6/+3
| | | | | | Not all code has been fixed yet; this is just a checkpoint... The C API still has PyDict_HasKey() and _HasKeyString(); not sure if I want to change those just yet.
* - Patch 1433928:Guido van Rossum2006-02-251-1/+6
| | | | | | | | - The copy module now "copies" function objects (as atomic objects). - dict.__getitem__ now looks for a __missing__ hook before raising KeyError. - Added a new type, defaultdict, to the collections module. This uses the new __missing__ hook behavior added to dict (see above).
* Use decorators.Guido van Rossum2005-01-161-1/+1
|
* The default argument in dict.setdefault() defaults to None.Walter Dörwald2004-05-271-1/+1
| | | | Add this default to UserDict.DictMixin.setdefault() too.
* SF #904720: dict.update should take a 2-tuple sequence like dict.__init_Raymond Hettinger2004-03-041-11/+17
| | | | | | | | (Championed by Bob Ippolito.) The update() method for mappings now accepts all the same argument forms as the dict() constructor. This includes item lists and/or keyword arguments.
* Make sure the UserDict copies do not share the same underlyingRaymond Hettinger2003-12-211-1/+1
| | | | | | | dictionary as the original. This parallels MvL's change to Lib/os.py 1.56. Backport candidate.
* SF bug #849662. Dramatically, improve comparison speed for "if shl == None".Raymond Hettinger2003-12-041-0/+2
|
* SF patch #693753: fix for bug 639806: default for dict.popRaymond Hettinger2003-03-061-4/+12
| | | | (contributed by Michael Stone.)
* typo in commentBarry Warsaw2003-01-311-1/+1
|
* SF patch #667730: More DictMixinRaymond Hettinger2003-01-221-2/+4
| | | | | | Sebastien Keim pointed out that iterkeys and __contains__ require their own definitions so their behavior will update when the underlying method is subclassed.
* Bring UserDict in-sync with changes to dict.Raymond Hettinger2002-11-271-6/+12
| | | | | | Constructor accepts optional keyword arguments after a optional items list. Add fromkeys() as an alternate constructor from an iterable over keys. Expand related unittests.
* Implement dict() style constructor.Raymond Hettinger2002-11-221-3/+8
| | | | | | | | | | | Already supported dict() and dict(mapping). Now supports dict(itemsequence) and Just van Rossum's new syntax for dict(keywordargs). Also, added related unittests. The docs already promise dict-like behavior so no update is needed there.
* Improve DictMixin.Raymond Hettinger2002-11-181-23/+38
| | | | | | | | | | | Replaced docstring with comments. Prevents subclass contamination. Added the missing __cmp__() method and a test for __cmp__(). Used try/except style in preference to has_key() followed by a look-up. Used iteritem() where possible to save creating a long key list and to save redundant lookups. Expanded .update() to look for the most helpful methods first and gradually work down to a mininum expected interface. Expanded documentation to be more clear on how to use the class.
* SF patch #520382: Expand shelve.py to have a full dictionary interfaceRaymond Hettinger2002-11-151-0/+64
| | | | | and add a mixin to UserDict.py to make it easier to implement a full dictionary interface.
* Add pop() to UserDict.Guido van Rossum2002-04-131-0/+2
|
* copy(): Make sure the copy of a derived class cannot share the data of theFred Drake2001-11-051-1/+8
| | | | | | original by replacing self.data temporarily, then using the update() method on the new mapping object to populate it. This closes SF bug #476616.
* Remove the __iter__ method from the UserDict class -- it can silentlyGuido van Rossum2001-08-071-0/+2
| | | | | | | | | | break old code (in extreme cases). See SF bug #448153. Add a new subclass IterableUserDict that has the __iter__ method. Note that for new projects, unless backwards compatibility with pre-2.2 Python is required, subclassing 'dictionary' is recommended; UserDict might become deprecated.
* Patch #413171: Implement get, setdefault, update in terms ofMartin v. Löwis2001-06-181-5/+7
| | | | has_key, __getitem__, and __setitem__.
* Added support for .iteritems(), .iterkeys(), .itervalues().Fred Drake2001-05-031-0/+3
|
* Give UserDict new __contains__ and __iter__ methods.Tim Peters2001-04-211-0/+4
|
* removed __all__ from several modulesSkip Montanaro2001-02-181-2/+0
|
* added __all__ lists to a number of Python modulesSkip Montanaro2001-01-201-0/+2
| | | | | | | | added test script and expected output file as well this closes patch 103297. __all__ attributes will be added to other modules without first submitting a patch, just adding the necessary line to the test script to verify more-or-less correct implementation.
* Add popitem().Guido van Rossum2000-12-121-0/+2
|
* Barry's patch to implement the new setdefault() method.Guido van Rossum2000-08-081-0/+4
|
* Mass patch by Ka-Ping Yee:Guido van Rossum2000-02-021-1/+1
| | | | | | | | | | | 1. Comments at the beginning of the module, before functions, and before classes have been turned into docstrings. 2. Tabs are normalized to four spaces. Also, removed the "remove" function from dircmp.py, which reimplements list.remove() (it must have been very old).
* Improved a bunch of things.Guido van Rossum1999-03-261-13/+16
| | | | | The constructor now takes an optional dictionary. Use isinstance() where appropriate.
* Mass check-in after untabifying all files that need it.Guido van Rossum1998-03-261-15/+15
|
* UserDict.get(): New method to mirror built-in dictionaries' get()Barry Warsaw1997-10-061-0/+5
| | | | method.
* Fix bug in copy() by using copy.copy() instead of making assumptionsGuido van Rossum1997-06-031-31/+25
| | | | | (it so happens that copy.copy() works fine for the base UserDict type). Also reindented the entire module to have 4-space indents.
* Added the new dictionary methods to the wrapper class.Fred Drake1997-06-031-0/+16
|
* * test_*.py: new lambda syntax (also affects tests for filter, map,Guido van Rossum1993-11-301-0/+18
reduce) * ftplib.py: added default callback for retrlines; added dir() method * ftplib.py: don't return self in self.connect(); added hack so that if 'CDUP' is not understood, 'CWD ..' is tried. * ftplib.py: second method called init() should have been called connect(); if __init__ sees more than one argument, it will also try to login().