<br><br><div class="gmail_quote">On Wed, May 9, 2012 at 10:50 AM, Antoine Pitrou <span dir="ltr"><<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Wed, 9 May 2012 10:44:59 -0400<br>
Brett Cannon <<a href="mailto:brett@python.org">brett@python.org</a>> wrote:<br>
><br>
> > I wish there was a builtin class<br>
> ><br>
> > class record:<br>
> > pass<br>
> ><br>
> > which can be used to create objects which have only attributes<br>
> > and no methods.<br>
><br>
><br>
> I have heard this request now a bazillion times over the years. Why don't<br>
> we have such an empty class sitting somewhere in the stdlib with a<br>
> constructor classmethod to simply return new instances (and if you want to<br>
> get really fancy, optional keyword arguments to update the instance with<br>
> the keys/values passed in)? Is it simply because it's just two lines of<br>
> Python that *everyone* has replicated at some point?<br>
<br>
</div>In this case, it's because sys is a built-in module written in C, and<br>
importing Python code is a no-go.<br></blockquote><div><br></div><div>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?</div>
<div><br></div><div>-Brett</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
We have a similar problem with ABCs: io jumps through hoops to register<br>
its implementation classes with the I/O ABCs.<br>
<br>
Regards<br>
<span class="HOEnZb"><font color="#888888"><br>
Antoine.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/brett%40python.org" target="_blank">http://mail.python.org/mailman/options/python-dev/brett%40python.org</a><br>
</div></div></blockquote></div><br>