<br><br><div class="gmail_quote">On Wed, May 9, 2012 at 10:50 AM, Antoine Pitrou <span dir="ltr">&lt;<a href="mailto:solipsis@pitrou.net" target="_blank">solipsis@pitrou.net</a>&gt;</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 &lt;<a href="mailto:brett@python.org">brett@python.org</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; I wish there was a builtin class<br>
&gt; &gt;<br>
&gt; &gt; class record:<br>
&gt; &gt; pass<br>
&gt; &gt;<br>
&gt; &gt; which can be used to create objects which have only attributes<br>
&gt; &gt; and no methods.<br>
&gt;<br>
&gt;<br>
&gt; I have heard this request now a bazillion times over the years. Why don&#39;t<br>
&gt; we have such an empty class sitting somewhere in the stdlib with a<br>
&gt; constructor classmethod to simply return new instances (and if you want to<br>
&gt; get really fancy, optional keyword arguments to update the instance with<br>
&gt; the keys/values passed in)? Is it simply because it&#39;s just two lines of<br>
&gt; Python that *everyone* has replicated at some point?<br>
<br>
</div>In this case, it&#39;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&#39;t we define this &quot;empty&quot; 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>

AltStyle によって変換されたページ (->オリジナル) /