Patches item #1094542, was opened at 2005-01-03 05:26 Message generated for change (Comment added) made by alanvgreen You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1094542&group_id=5470
Category: None Group: Python 2.5 Status: Open Resolution: None Priority: 5 Submitted By: Steven Bethard (bediviere) Assigned to: Nobody/Anonymous (nobody) Summary: add Bunch type to collections module Initial Comment: This patch adds a proposed Bunch type to the collections module which complements Python's dict type, which provides a name-value mapping through the __getitem__ protocol, with the Bunch type, which provides an attribute-value mapping through dotted-attribute access. Example: >>> x = Bunch(spam=Bunch(rabbit=1, badger=[2, 3, 4]), ham='neewom') >>> x.spam.badger [2, 3, 4] >>> x.ham 'neewom' ---------------------------------------------------------------------- Comment By: Alan Green (alanvgreen) Date: 2005-01-24 23:34 Message: Logged In: YES user_id=1174944 Some thoughts while we wait for the PEP: 1. This doesn't look like a collection class to me. It's more of a convenient substitute for a first-class object. The PEP would need to include a rationale as to why this class is in the collections module. 2. It may be desireable to make the core parts of Bunch (equality test, repr, and update) available as functions that other classes can use if appropriate. This might help developers building objects more complex than a Bunch. Then again, maybe not, but I'd like to see the PEP address this. 3. The docstring on __eq__ should explicitly say what consitutes equality for bunches: both bunches have the same attributes and the same values for those attributes. 4. It's easy enough to convert a dict to a Bunch (via the Bunch constructor), but I would have expected that there be a way to convert a Bunch to a dict. Overall, a useful concept, but I'd like to read the PEP - you could always upload your draft to this patch item :) ---------------------------------------------------------------------- Comment By: Steven Bethard (bediviere) Date: 2005-01-11 02:15 Message: Logged In: YES user_id=945502 I submitted a PEP for it on 2 Jan 2005, but I haven't heard back from [EMAIL PROTECTED] yet. Sorry, I didn't realize it might take so long to get a PEP number. ---------------------------------------------------------------------- Comment By: Michael Chermside (mcherm) Date: 2005-01-11 01:08 Message: Logged In: YES user_id=99874 Would someone be willing to provide the motivation for adding this class? I'm certainly willing to listen, but I'm not convinced this is worth adding to the std library. (I guess that's a -0 vote.) ---------------------------------------------------------------------- Comment By: Reinhold Birkenfeld (birkenfeld) Date: 2005-01-04 04:38 Message: Logged In: YES user_id=1188172 Let me add that the main functionality consists in the easy initializing and updating (otherwise, you just could use an empty class). I'm +1 on the class, but I would call it `bunch'. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1094542&group_id=5470 _______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
