[Python-Dev] Re: Re: Re: Patch review: [ 1094542 ] add Bunch type to collections module (original) (raw)

Steven Bethard steven.bethard at gmail.com
Fri Jan 28 02:54:04 CET 2005


On Thu, 27 Jan 2005 18:31:55 -0700, Fernando Perez <fperez.net at gmail.com> wrote:

However, I think it would perhaps be best to advertise any methods of Bunch as strictly classmethods from day 1. Otherwise, you can have:

b = Bunch() b.update(otherdict) -> otherdict happens to have an 'update' key ... more code b.update(someotherdict) -> boom! update is not callable If all Bunch methods are officially presented always as classmethods, users can simply expect that all attributes of a bunch are meant to store data, without any instance methods at all.

That sounds reasonable to me. I'll fix update to be a staticmethod. If people want other methods, I'll make sure they're staticmethods too.[1]

Steve

[1] In all the cases I can think of, staticmethod is sufficient -- the methods don't need to access any attributes of the Bunch class. If anyone has a good reason to make them classmethods instead, let me know...

-- You can wordify anything if you just verb it. --- Bucky Katt, Get Fuzzy



More information about the Python-Dev mailing list