Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2709

Re: is python 3 better than python 2?

Date 2011-04-06 17:31 +0100
From MRAB <python@mrabarnett.plus.com>
Subject Re: is python 3 better than python 2?
References <mailman.42.1302007551.9059.python-list@python.org> <inf9vi$nvm$1@dont-email.me> <4d9b7eaa$0$10570$742ec2ed@news.sonic.net> <ings9q$qse$2@dough.gmane.org> <BANLkTi=waQzxrCfVhsnjB-Q5jnW7EJtpPA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.79.1302107467.9059.python-list@python.org> (permalink)

Show all headers | View raw


On 06/04/2011 07:06, Dan Stromberg wrote:
>
> On Tue, Apr 5, 2011 at 10:04 PM, Terry Reedy <tjreedy@udel.edu
> <mailto:tjreedy@udel.edu>> wrote:
>
>     On 4/5/2011 4:42 PM, John Nagle wrote:
>
>         Well, actually Unicode support went in back around Python 2.4.
>
>
>     Even earlier, I think, but there were and still are problems with
>     unicode in 2.x. Some were and will only be fixed in 3.x.
>
>
>         In 3.x, ASCII strings went away, but that was more of a removal.
>
>
>     Yes and no. They were kept slightly modified as bytes, with all of
>     the string methods kept.
>
>
> I suspect not all string methods were kept for the bytes type:
> $ /usr/local/cpython-3.2/bin/python
> cmd started 2011 Tue Apr 05 11:05:08 PM
> Python 3.2 (r32:88445, Feb 20 2011, 16:47:11)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> 'a/b/c'.split('/')
> ['a', 'b', 'c']
>  >>> b'a/b/c'.split('/')
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> TypeError: Type str doesn't support the buffer API
>  >>>
>
You're trying to split bytes with a str (Unicode) argument. Try this:

 >>> b'a/b/c'.split(b'/')
[b'a', b'b', b'c']

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

is python 3 better than python 2? neil <neilharper300890@gmail.com> - 2011-04-05 13:42 +0100
  Re: is python 3 better than python 2? Mel <mwilson@the-wire.com> - 2011-04-05 14:46 +0000
    Re: is python 3 better than python 2? John Nagle <nagle@animats.com> - 2011-04-05 13:42 -0700
      Re: is python 3 better than python 2? Terry Reedy <tjreedy@udel.edu> - 2011-04-06 01:04 -0400
      Re: is python 3 better than python 2? MRAB <python@mrabarnett.plus.com> - 2011-04-06 17:31 +0100
      Re: is python 3 better than python 2? Terry Reedy <tjreedy@udel.edu> - 2011-04-06 13:01 -0400
      Re: is python 3 better than python 2? Dan Stromberg <drsalists@gmail.com> - 2011-04-06 13:14 -0700
  Re: is python 3 better than python 2? Gnarlodious <gnarlodious@gmail.com> - 2011-04-05 09:50 -0700

csiph-web