classification
Title: Full example for emulating a container type
Type: Stage:
Components: Documentation Versions: Python 2.6, Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: georg.brandl, ngie, rhettinger
Priority: normal Keywords:

Created on 2009-04-27 01:20 by ngie, last changed 2009-05-03 04:26 by ngie. This issue is now closed.

Files
File name Uploaded Description Edit
somecontainerclass.py ngie, 2009-04-27 01:20
Messages (5)
msg86637 - (view) Author: Enji Cooper (ngie) * Date: 2009-04-27 01:20
This is just an example that I want to offer to the community to help
improve overall documentation in the handbook.

I've attached the example file, but it's also available on my journal
post with example output: http://yaneurabeya.livejournal.com/3437.html
msg86638 - (view) Author: Enji Cooper (ngie) * Date: 2009-04-27 01:22
BTW, the documentation item that this should be attached to is:
http://docs.python.org/reference/datamodel.html#emulating-container-types
msg86685 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-04-27 17:05
I think we've got this covered with the examples for the collections
module ABCs.  We have one for ListBasedSet and are adding a link for to
an OrderedSet recipe.   The ABCs themselves provide a clear path on how
to implement major container types.  The UserDict, UserList, and
UserString classes are also worked-out examples.
msg86757 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-28 17:57
May I add that the given example is flawed:

1. it shares the data dictionary between all instances
2. just delegating all container interfaces to a dictionary does not
really show how to customize your own container.
msg86997 - (view) Author: Enji Cooper (ngie) * Date: 2009-05-03 04:26
Maybe the documentation for other examples should be referenced then?
History
Date User Action Args
2009-05-03 04:26:08ngiesetmessages: + msg86997
2009-04-28 18:36:46rhettingersetstatus: open -> closed
resolution: rejected
2009-04-28 17:57:53georg.brandlsetmessages: + msg86757
2009-04-27 17:05:31rhettingersetassignee: georg.brandl -> rhettinger

messages: + msg86685
nosy: + rhettinger
2009-04-27 01:22:01ngiesetmessages: + msg86638
2009-04-27 01:20:37ngiecreate