Commit Graph

31 Commits

Author SHA1 Message Date
Raymond Hettinger 4f1e16338d Fix field name conflicts for named tuples. 2009-05-27 02:17:26 +00:00
Raymond Hettinger 38f57a1c75 Issue #5647: MutableSet.__iand__() no longer mutates self during iteration. 2009-04-01 18:55:57 +00:00
Raymond Hettinger 9293eb965a Backport 69934: Register xrange() as a Sequence. 2009-02-24 12:25:32 +00:00
Raymond Hettinger c979448507 Issue 4920: Fixed next() vs __next__() issues in the ABCs
for Iterator and MutableSet.  Also added thorough test for
required abstractmethods.
2009-01-28 23:14:58 +00:00
Raymond Hettinger 6ee7bc04f7 Fix namedtuple bug reported by Glenn Linderman. Template did not form correctly if the field names were input in Unicode. 2008-09-25 23:31:52 +00:00
Nick Coghlan 48361f5cbf Issue 2235: Py3k warnings are now emitted for classes that will no longer inherit a__hash__ implementation from a parent class in Python 3.x. The standard library and test suite have been updated to not emit these warnings. 2008-08-11 15:45:58 +00:00
Raymond Hettinger 4c52f52ef3 Issue 3161: Missing import and test. 2008-06-23 03:29:28 +00:00
Raymond Hettinger e98839a1f4 Issue3065: Fixed pickling of named tuples. Added tests. 2008-06-09 01:28:30 +00:00
Georg Brandl 0bb0299ad8 Take namedtuple item names only from ascii_letters (this blew up on OSX),
and make sure there are no duplicate names.
2008-05-18 10:39:26 +00:00
Amaury Forgeot d'Arc cb0f2ad0c2 A DocTestSuite cannot run multiple times: it clears its globals dictionary after the first run.
Rebuild the DocTestSuite on each iteration.
2008-04-02 00:55:04 +00:00
Raymond Hettinger d1ef85420f Run doctests on the collections module 2008-01-11 00:23:13 +00:00
Raymond Hettinger 1b50fd7cb3 Add error-checking to namedtuple's _replace() method. 2008-01-05 02:17:24 +00:00
Raymond Hettinger 02740f73ff Improve namedtuple's _cast() method with a docstring, new name, and error-checking. 2008-01-05 01:35:43 +00:00
Raymond Hettinger e0734e7dc0 Minor fix-ups to named tuples:
* Make the _replace() method respect subclassing.

* Using property() to make _fields read-only wasn't a good idea.
  It caused len(Point._fields) to fail.

* Add note to _cast() about length checking and alternative with the star-operator.
2008-01-04 03:22:53 +00:00
Raymond Hettinger 85dfcf3530 Users demand iterable input for named tuples. The author capitulates. 2007-12-18 23:51:15 +00:00
Raymond Hettinger 88880b2dd6 Add more namedtuple() test cases. Neaten the code and comments. 2007-12-18 00:13:45 +00:00
Raymond Hettinger 42da874cdd Cleaner method naming convention 2007-12-14 02:49:47 +00:00
Raymond Hettinger 2e1af256d4 Error checking was too aggressive (reported by Chris Tismer) 2007-12-05 18:11:08 +00:00
Guido van Rossum 64c06e327d Backport of _abccoll.py by Benjamin Arangueren, issue 1383.
With some changes of my own thrown in (e.g. backport of r58107).
2007-11-22 00:55:51 +00:00
Raymond Hettinger eeeb9c4445 Accept Issac Morland's suggestion for __replace__ to allow multiple replacements
(suprisingly, this simplifies the signature, improves clarity, and is comparably fast).
Update the docs to reflect a previous change to the function name.
Add an example to the docs showing how to override the default __repr__ method.
2007-11-15 02:44:53 +00:00
Raymond Hettinger b5e5d0741a Add test for __fields__ being read-only 2007-11-14 23:02:30 +00:00
Raymond Hettinger 01a0957f06 Shorter name for namedtuple() 2007-10-23 20:37:41 +00:00
Raymond Hettinger abfd8dff3b More docs, error messages, and tests 2007-10-16 21:28:32 +00:00
Raymond Hettinger a48a29947a Eliminate camelcase function name 2007-10-08 21:26:58 +00:00
Raymond Hettinger 2115bbc4da Add comments to NamedTuple code.
Let the field spec be either a string or a non-string sequence (suggested by Martin Blais with use cases).
Improve the error message in the case of a SyntaxError (caused by a duplicate field name).
2007-10-08 09:14:28 +00:00
Raymond Hettinger a7fc4b13e0 Add __asdict__() to NamedTuple and refine the docs.
Add maxlen support to deque() and fixup docs.
Partially fix __reduce__().  The None as a third arg was no longer supported.
Still needs work on __reduce__() to handle recursive inputs.
2007-10-05 02:47:07 +00:00
Raymond Hettinger 2b03d45bb9 Handle corner cased on 0-tuples and 1-tuples. Add verbose option so people can see how it works. 2007-09-18 03:33:19 +00:00
Raymond Hettinger d36a60e1e3 Sync-up named tuples with the latest version of the ASPN recipe.
Allows optional commas in the field-name spec (help when named tuples are used in conjuction with sql queries).
Adds the __fields__ attribute for introspection and to support conversion to dictionary form.
Adds a  __replace__() method similar to str.replace() but using a named field as a target.
Clean-up spelling and presentation in doc-strings.
2007-09-17 00:55:00 +00:00
Raymond Hettinger 767debb6aa Allow all alphanumeric and underscores in type and field names. 2007-05-21 16:40:10 +00:00
Raymond Hettinger 5a41daf096 Improvements to NamedTuple's implementation, tests, and documentation 2007-05-19 01:11:16 +00:00
Raymond Hettinger c37e5e04eb Add collections.NamedTuple 2007-03-01 06:16:43 +00:00