<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, 21 Jan 2016 at 10:45 Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 21, 2016 at 10:14 AM, Agustín Herranz Cecilia <span dir="ltr"><<a href="mailto:agustin.herranz@gmail.com" target="_blank">agustin.herranz@gmail.com</a>></span> wrote:<br></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><div><div>
<div>El 2016/01/21 a las 1:11, Guido van
Rossum escribió:<br>
</div></div></div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><div><div>[...]<br>
</div></div></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span><blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">[SNIP] <br></div></div></div></blockquote></span></div></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>
> - Also there must be addressed how it work on a
python2 to python3 environment as there are types with
the same name, str for example, that works differently
on each python version. If the code is for only one
version uses the type names of that version.<br>
<br>
</span>That's the same problem that exists at runtime, and
people (and tools) already know how to deal with it: use
bytes when you mean bytes, unicode when you mean unicode,
and str when you mean whatever is "native" to the version
you're running under and are willing to deal with it. So
now you just have to do the same thing in type hints that
you're already doing in constructors, isinstance checks,
etc.<br>
</blockquote>
<div><br>
</div>
<div>This is actually still a real problem. But it has no
bearing on the choice of syntax for annotations in Python
2 or straddling code.<br>
</div>
</div>
</div>
</div>
</blockquote>
<br></span>
Yes, this is no related with the choice of syntax for annotations
directly. This is intended to help in the process of porting python2
code to python3, and it's outside of the PEP scope but related to
the original problem. What I have in mind is some type aliases so
you could annotate a version specific type to avoid ambiguousness on
code that it's used on different versions. At the end what I
originally try to said is that it's good to have a convention way to
name this type aliases.<br></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Yes, this is a useful thing to discuss.<br><br></div><div>Maybe we can standardize on the types defined by the 'six' package, which is commonly used for 2-3 straddling code:<br><br></div><div>six.text_type (unicode in PY2, str in PY3)<br></div><div>six.binary_type (str in PY2, bytes in PY3)<br><br></div><div>Actually for the latter we might as well use bytes.</div></div></div></div></blockquote><div><br></div><div>I agree that `bytes` should cover str/bytes in Python 2 and `bytes` in Python 3.</div><div><br></div><div>As for the textual type, I say either `text` or `unicode` since they are both unambiguous between Python 2 and 3 and get the point across.</div><div><br></div><div>And does `str` represent the type for the specific version of Python mypy is running under, or is it pegged to a specific representation across Python 2 and 3? If it's the former then fine, else those people who use the "native string" concept might want a way to say "I want the `str` type as defined on the version of Python I'm running under" (personally I don't promote the "native string" concept, but I know it has been brought up in the past).</div><div><br></div><div>-Brett</div></div></div>