Guido van Rossum wrote:
> Please comment.
> [...]
> Conversions between bytes or buffer objects and str objects must
> always be explicit, using an encoding. There are two equivalent APIs:
> ``str(b, [, ])`` is equivalent to
> ``b.encode([, ])``, and
> ``bytes(s, [, ])`` is equivalent to
> ``s.d
Guido van Rossum wrote:
> Thinking through the consequences, and noticing that using the array
> module as an ersatz mutable bytes type is far from ideal, and
> recalling a proposal put forward earlier by Talin, I floated the
> suggestion to have both a mutable and an immutable bytes type. (This
>
> **Open Issue:** I'm undecided on whether indexing bytes and buffer
> objects should return small ints (like the bytes type in 3.0a1, and
> like lists or array.array('B')), or bytes/buffer objects of length 1
> (like the str type). The latter (str-like) approach will ease porting
> code from Pyth
On 9/26/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote:
> I think indexing a bytes/buffer object should return an int.
> I find this behavior more natural, to me, than using an
> ord()-like function to extract values.
I didn't known about the length-1 comparison issue when I wrote this.
Person
Guido van Rossum wrote:
> [PEP 3137]
>>> **Open Issue:** I'm undecided on whether indexing bytes and buffer
>>> objects should return small ints (like the bytes type in 3.0a1, and
>>> like lists or array.array('B')), or bytes/buffer objects of length 1
>>> (like the str type). The latter (str-like
Guido van Rossum <[EMAIL PROTECTED]> wrote:
> However there's quite a bit of Python 2.x code around that manipulates
> *bytes* in the guise of 8-bit strings, and it uses tests like "if s[0]
>== 'x': ..." frequently.
I think it would be useful to do a survey and see how much code
would be affected
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I've uploaded the latest code to http://umass.glexia.net/mpf.tar.bz2
Here's a quick rundown of supported functions and operations.
The MPF() constructor accepts a string and an optional keyword
argument, prec, specifying precision (as a Long).
Suppo
> Making an iterator over an integer sequence acceptable in the
> constructor strongly suggests that a byte sequence contains integers
> between 0 and 255 inclusive, not length 1 byte sequences.
>
> And I think that's the cleanest conceptual model for them as well. A
> byte sequence doesn't con
On 9/27/07, Neil Schemenauer <[EMAIL PROTECTED]> wrote:
> Guido van Rossum <[EMAIL PROTECTED]> wrote:
> > However there's quite a bit of Python 2.x code around that manipulates
> > *bytes* in the guise of 8-bit strings, and it uses tests like "if s[0]
> >== 'x': ..." frequently.
>
> I think it woul
I think I've been convinced that b[0] should return an int in range(256).
To Joel Bender: octet is not, and never will be a technical term for
Python. It is a silly standards body compromise.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
I didn't miss it, and I don't disagree, I just don't think it has much
bearing on the discussion (which is whether to go with this proposal
at all).
On 9/27/07, Talin <[EMAIL PROTECTED]> wrote:
> Guido van Rossum wrote:
> > Thinking through the consequences, and noticing that using the array
> > m
On 9/27/07, Joel Bender <[EMAIL PROTECTED]> wrote:
> First, please enforce that where these functions take a "string"
> parameter that they require an octet or octet string (I couldn't find
> what kinds of arguments these functions require in PEP 3118):
>
> >>> x = b'123*45'
> >>> x.find(
On 9/26/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> Comparisons
> ---
> The bytes and buffer types are comparable with each other and
> orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'.
I think bytes (regardless of length) should compare to integers, so that:
b"" < -s
On 9/27/07, Jim Jewett <[EMAIL PROTECTED]> wrote:
> On 9/26/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
>
> > Comparisons
> > ---
>
> > The bytes and buffer types are comparable with each other and
> > orderable, so that e.g. b'abc' == buffer(b'abc') < b'abd'.
>
> I think bytes (regardl
Guido van Rossum wrote:
I think I've been convinced that b[0] should return an int in range(256).
This made me feel funny. I stared at this for a while:
b'a' != b'abcde'[0] ?!?
b'a'[0] != b'a' ?!?
Then I realized that making b[0] return an int simply makes bytes
objects behave less li
Gregory P. Smith wrote:
> Would a special case in the b'x' comparison tests that knows how to
> compare a len==1 bytes (mutable or not) object to an integer be
> reasonable or just alternately confusing?
Comparison isn't the only thing you might want to do
with bytes. Doing this just for compariso
On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> argc/argv does not exist on Windows (that you seem to see it
> anyway is an illusion), and if it did exist, it would be characters,
> not bytes.
Of course it exists on Windows. argc/argv are defined by the C
standard, and say what you wil
Alexandre Vassalotti wrote:
> Personally, I wouldn't mind writing either this:
>
>for b in bytes:
> if b == b'a'[0]:
>pass
Well, I would mind, because it's needlessly verbose
and inefficient.
I still think that c'x' is the least bad solution. As long
as we're wanting to write ar
Nick Coghlan wrote:
> However, I do think it may be worth having an additional iterator on
> bytes and buffer objects:
>
>def fragments(self, size=1): # Could do with a better name
I suggest dice(). :-)
--
Greg Ewing, Computer Science Dept, +--+
Universi
Larry Hastings wrote:
> So now bytes are straddling the difference between strings and the other
> mapping types:
I think the main reason it seems that way is that we're
using a string-like notation for a bytes literal. With
b[i] returning an int, it really behaves just like any
other sequence.
Nicholas Bastin schrieb:
> On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> argc/argv does not exist on Windows (that you seem to see it
>> anyway is an illusion), and if it did exist, it would be characters,
>> not bytes.
>
> Of course it exists on Windows. argc/argv are defined by th
On 9/27/07, Nicholas Bastin <[EMAIL PROTECTED]> wrote:
>
> On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > argc/argv does not exist on Windows (that you seem to see it
> > anyway is an illusion), and if it did exist, it would be characters,
> > not bytes.
>
> Of course it exists on Win
On 9/28/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> Nicholas Bastin schrieb:
> > On 9/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >> argc/argv does not exist on Windows (that you seem to see it
> >> anyway is an illusion), and if it did exist, it would be characters,
> >> not bytes
23 matches
Mail list logo