<div>On Wed, Mar 7, 2012 at 5:45 PM, Victor Stinner <span dir="ltr">&lt;<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>&gt;</span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">&gt; During the Language Summit 2011 (*), it was discussed that PyPy and<br>
&gt; Jython don&#39;t support non-string key in type dict. An issue was open to<br>
&gt; emit a warning on such dict, but the patch has not been commited yet.<br>
<br>
</div>It&#39;s the issue #11455. As written in the issue, there are two ways to<br>
create such type:<br>
<br>
class A(object):<br>
    locals()[42] = &quot;abc&quot;<br>
<br>
or<br>
<br>
type(&quot;A&quot;, (object,), {42: &quot;abc&quot;})<br>
<br>
Both look like an ugly hack.<br></blockquote><div><br></div><div>Here is a cleaner version, using metaclasses (Python 2.6):</div><div><br></div><div><div>class M(type):</div><div>    def __new__(mcs, name, bases, dict):</div>

<div>            dict[42] = &#39;abc&#39;</div><div>            return super(M, mcs).__new__(mcs, name, bases, dict)</div><div><br></div><div>class A(object):</div><div>    __metaclass__ = M</div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div class="HOEnZb"><div class="h5"><br>
Victor<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/ckaynor%40zindagigames.com" target="_blank">http://mail.python.org/mailman/options/python-dev/ckaynor%40zindagigames.com</a><br>
</div></div></blockquote></div><br>