<div>On Wed, Mar 7, 2012 at 5:45 PM, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>></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">> During the Language Summit 2011 (*), it was discussed that PyPy and<br>
> Jython don't support non-string key in type dict. An issue was open to<br>
> emit a warning on such dict, but the patch has not been commited yet.<br>
<br>
</div>It'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] = "abc"<br>
<br>
or<br>
<br>
type("A", (object,), {42: "abc"})<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] = 'abc'</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>