A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-June/101060.html below:

[Python-Dev] thoughts on the bytes/string discussion

[Python-Dev] thoughts on the bytes/string discussionIan Bicking ianb at colorstudy.com
Fri Jun 25 17:40:56 CEST 2010
On Fri, Jun 25, 2010 at 5:06 AM, Stephen J. Turnbull <stephen at xemacs.org>wrote:

>   > So with this idea in mind it makes more sense to me that *specific
> pieces of
>  > text* can be reasonably treated as both bytes and text.  All the string
>  > literals in urllib.parse.urlunspit() for example.
>  >
>  > The semantics I imagine are that special('/')+b'x'==b'/x' (i.e., it does
> not
>  > become special('/x')) and special('/')+x=='/x' (again it becomes str).
>  This
>  > avoids some of the cases of unicode or str infecting a system as they
> did in
>  > Python 2 (where you might pass in unicode and everything works fine
> until
>  > some non-ASCII is introduced).
>
> I think you need to give explicit examples where this actually helps
> in terms of "type contagion".  I expect that it doesn't help at all,
> especially not for the people whose native language for URIs is bytes.
> These specials are still going to flip to unicode as soon as it comes
> in, and that will be incompatible with the bytes they'll need later.
> So they're still going to need to filter out unicode on input.
>
> It looks like it would be useful for programmers of polymorphic
> functions, though.
>

I'm proposing these specials would be used in polymorphic functions, like
the functions in urllib.parse.  I would not personally use them in my own
code (unless of course I was writing my own polymorphic functions).

This also makes it less important that the objects be a full stand-in for
text, as their use should be isolated to specific functions, they aren't
objects that should be passed around much.  So you can easily identify and
quickly detect if you use unsupported operations on those text-like
objects.  (This is all a very different use case from bytes+encoding, I
think)

-- 
Ian Bicking  |  http://blog.ianbicking.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100625/0d7f7e84/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4