[Python-ideas] a simple namespace type (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sun May 27 22:09:06 CEST 2012
- Previous message: [Python-ideas] a simple namespace type
- Next message: [Python-ideas] a simple namespace type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Slightly easier bar to reach: could the various incarnations be improved by using a new varobject type as a base class (e.g. I know I often use namedtuple as a base class rather than instantiating them directly, although I do the latter, too).
There's also a potentially less controversial alternative: just add an easy spelling for "type(name, (), {})" to the C API.
-- Sent from my phone, thus the relative brevity :) On May 28, 2012 5:54 AM, "Eric V. Smith" <eric at trueblade.com> wrote:
On 5/27/2012 3:31 PM, Calvin Spealman wrote: > On Sun, May 27, 2012 at 1:58 PM, T.B. <bauertomer at gmail.com> wrote: >> On 2012-05-27 19:08, Sven Marnach wrote: >>> Calvin Spealman schrieb am Sun, 27. May 2012, um 09:42:26 -0400: >>>> - record >>>> - flexobject >>>> - attrobject >>>> - attrdict >>>> - nameddict >>>> - namedobject >>> >>> Since the proposed type is basically an
object
allowing attributes, >>> another option would beattrobject
. >>> >>> Adding an_iter_()
method, as proposed earlier in this thread, >>> seems unnecessary; you can simply iterate overvars(x)
for an >>>attrobject
instancex
. >>> >> >> Is this whole class really necessary? As said before, this type is >> implemented numerous times: >> * empty class (included in the Python Tutorial) [1] >> * argparse.Namespace [2] >> * multiprocessing.managers.Namespace [3] >> * bunch (PyPI) that inherits from dict, instead of wrapping dict [4] >> * many more... > > All of the re-implementations of essentially the same thing is exactly why a > standard version is constantly suggested. > > That said, it is so simple that it easily has many variants, because it is only > the base of the different ideas all these things implement.A test of the concept would be: could the uses of the similar classes in the standard library be replaced with the proposed new implementation? Eric.
Python-ideas mailing list Python-ideas at python.org http://mail.python.org/mailman/listinfo/python-ideas -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120528/78e7d99f/attachment.html>
- Previous message: [Python-ideas] a simple namespace type
- Next message: [Python-ideas] a simple namespace type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]