<div dir="ltr">Yes, I'd expect the keys to be newstr, since that would match python3 behavior.<div><br></div><div>Here's my udict:</div><div><br></div><div><br></div><div><pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51,51,51);line-height:18px">
<div class="" id="LC63" style="padding-left:10px;height:18px"><span class="" style="font-weight:bold">def</span> <span class="" style="color:rgb(153,0,0);font-weight:bold">udict</span><span class="">(</span><span class="" style="font-weight:bold">*</span><span class="">args</span><span class="">,</span> <span class="" style="font-weight:bold">**</span><span class="">kwargs</span><span class="">):</span></div>
<div class="" id="LC64" style="padding-left:10px;height:18px">    <span class="" style="color:rgb(221,17,68)">"""Similar to dict(), but keyword-keys are text.</span></div><div class="" id="LC65" style="padding-left:10px;height:18px">
<span class="" style="color:rgb(221,17,68)">    TODO: refactor out udict in favor of future.newdict</span></div><div class="" id="LC66" style="padding-left:10px;height:18px"><span class="" style="color:rgb(221,17,68)">    """</span></div>
<div class="" id="LC67" style="padding-left:10px;height:18px">    <span class="">kwargs</span> <span class="" style="font-weight:bold">=</span> <span class="" style="color:rgb(0,134,179)">dict</span><span class="">([</span></div>
<div class="" id="LC68" style="padding-left:10px;height:18px">        <span class="">(</span><span class="">u</span><span class="">(</span><span class="">key</span><span class="">),</span> <span class="">val</span><span class="">)</span></div>
<div class="" id="LC69" style="padding-left:10px;height:18px">        <span class="" style="font-weight:bold">for</span> <span class="">key</span><span class="">,</span> <span class="">val</span> <span class="" style="font-weight:bold">in</span> <span class="">kwargs</span><span class="" style="font-weight:bold">.</span><span class="">items</span><span class="">()</span></div>
<div class="" id="LC70" style="padding-left:10px;height:18px">    <span class="">])</span></div><div class="" id="LC71" style="padding-left:10px;height:18px"><br></div><div class="" id="LC72" style="padding-left:10px;height:18px">
    <span class="" style="font-weight:bold">return</span> <span class="" style="color:rgb(0,134,179)">dict</span><span class="">(</span><span class="" style="font-weight:bold">*</span><span class="">args</span><span class="">,</span> <span class="" style="font-weight:bold">**</span><span class="">kwargs</span><span class="">)</span></div>
</pre></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 19, 2014 at 4:30 AM, Ed Schofield <span dir="ltr"><<a href="mailto:ed@pythoncharmers.com" target="_blank">ed@pythoncharmers.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div><div class="h5"><div>On 14 May 2014, at 3:40 am, Buck Golemon <<a href="mailto:buck.2019@gmail.com" target="_blank">buck.2019@gmail.com</a>> wrote:</div>
<br></div></div><blockquote type="cite"><div dir="ltr"><div><div class="h5"><div style="font-family:arial,sans-serif;font-size:13px">As I understand it, the contract of future.builtins is to act like the python3 builtins, but this behavior is distinctly python2-ish (and necessitates me to write my own `udict`).</div>

<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">>>> dict</div><div style="font-family:arial,sans-serif;font-size:13px"><class 'future.builtins.types.newdict.newdict'></div>

<div style="font-family:arial,sans-serif;font-size:13px">>>> type(tuple(dict(a=1).keys())[0]).mro()</div></div></div><div style="font-family:arial,sans-serif;font-size:13px">[<type 'str'>, <type 'basestring'>, <type 'object’>]</div>
</div></blockquote><div><br></div><div>Hi Buck,</div><div><br></div><div>Yes, the type of ‘a’ is a native string. This seems to be what Python does when passing a kwarg to a function. Can you think of a way around this? </div>
<div><br></div><div>What would you prefer to happen instead? Would you prefer for ``dict(a=1)`` to give you a dict with a ``newstr`` as the key? What is the application you have in mind?</div><div><br></div><div>I would be interested in seeing your ``udict`` class to consider whether ``future.types.newdict`` can be modified to meet this need.</div>
<div><br></div><div>Best wishes,</div><div>    Ed</div><div><br></div><div><br></div><div><br></div></div><br><div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<span style="font-size:13px;background-color:rgb(255,255,255);color:rgb(102,102,102)">--</span></div><div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<span style="font-size:13px;background-color:rgb(255,255,255);color:rgb(102,102,102)">Dr. Edward Schofield</span><br style="font-size:13px;background-color:rgb(255,255,255);color:rgb(102,102,102)"><span style="font-size:13px;background-color:rgb(255,255,255);color:rgb(102,102,102)">Python Charmers</span><br style="font-size:13px;background-color:rgb(255,255,255);color:rgb(102,102,102)">
<span style="font-size:13px;background-color:rgb(255,255,255);color:rgb(102,102,102)"><a href="http://pythoncharmers.com/" style="color:rgb(0,106,227)" target="_blank">http://pythoncharmers.com</a></span></div></div>
</div>
<br></div></blockquote></div><br></div>