[Python-ideas] Type hints for text/binary data in Python 2+3 code

Wes Turner wes.turner at gmail.com
Wed Mar 23 02:12:35 EDT 2016


* Text.encoding
* Text.lang (urn:ietf:rfc:3066)
*

...  IRIs and RDF literals may be useful test cases here:

* https://en.m.wikipedia.org/wiki/Comparison_of_Unicode_encodings
  * https://en.m.wikipedia.org/wiki/Control_character
* https://en.wikipedia.org/wiki/Internationalized_resource_identifier
  * is this already punycoded?
* http://rdflib.readthedocs.org/en/stable/rdf_terms.html
  *
http://rdflib.readthedocs.org/en/stable/apidocs/rdflib.html#rdflib.term.Literal
    (value, datatype, lang (RFC 3066))
On Mar 22, 2016 4:40 PM, "Wes Turner" <wes.turner at gmail.com> wrote:

>
> On Mar 22, 2016 4:36 PM, "Andrey Vlasovskikh" <
> andrey.vlasovskikh at gmail.com> wrote:
> >
> >
> > > 2016-03-19, в 5:12, Wes Turner <wes.turner at gmail.com> написал(а):
> > >
> > > This sounds like a more correct approach, thanks.
> > >
> > > Looking at MarkupSafe (and, now, f-strings), would/will it be possible
> to use Typing.Text as a base class for even-more abstract string types
> ("strypes") e.g. XML, XHTML, HTML4, HTML5, HTML5.1, SQL? There are implicit
> casts and contextual adaptations/transformations (which MarkupSafe specs a
> bit). (I've no real code here, just a general idea that we're not tracking
> enough string metadata to be safe here)
> >
> > I believe having separate string types for XML or SQL content is out of
> the scope of this proposal.
> >
> > In PyCharm we already treat the contents of string literals with SQL as
> a separate SQL syntax tree and we understand basic string operations like
> concatenation or formatting. Going beyond that with the help of
> XML/SQL/etc. string types is possible, but I doubt we need a standard for
> that.
>
> At the least, it would be helpful to either have:
>
> a) a slot / attribute for additional string type metadata (is this an
> object subclass that I can just add attrs to)
> b) a minimal Text base class
>
> SQL is harder because dialects.
>
> >
> > --
> > Andrey Vlasovskikh
> >
> > Web: http://pirx.ru/
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160323/06d4ed52/attachment.html>


More information about the Python-ideas mailing list