On Wed, May 9, 2012 at 10:50 AM, Antoine Pitrou <solipsis at pitrou.net> wrote: > On Wed, 9 May 2012 10:44:59 -0400 > Brett Cannon <brett at python.org> wrote: > > > > > I wish there was a builtin class > > > > > > class record: > > > pass > > > > > > which can be used to create objects which have only attributes > > > and no methods. > > > > > > I have heard this request now a bazillion times over the years. Why don't > > we have such an empty class sitting somewhere in the stdlib with a > > constructor classmethod to simply return new instances (and if you want > to > > get really fancy, optional keyword arguments to update the instance with > > the keys/values passed in)? Is it simply because it's just two lines of > > Python that *everyone* has replicated at some point? > > In this case, it's because sys is a built-in module written in C, and > importing Python code is a no-go. > Sure, but couldn't we define this "empty" class in C code so that you can use the C API with it as well and just provide a C function to get a new instance? -Brett > > We have a similar problem with ABCs: io jumps through hoops to register > its implementation classes with the I/O ABCs. > > Regards > > Antoine. > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/brett%40python.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120509/bcbffaac/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4