En Sun, 28 Sep 2008 07:01:12 -0300, Olivier Lauzanne
<[EMAIL PROTECTED]> escribió:
On Sep 28, 11:21 am, est <[EMAIL PROTECTED]> wrote:
Can anyone tell me how to customize a default encoding, let's say
'ansi' which handles range(256) ?
I assume you are using python2.5
Edit the file /usr/lib/
In message
<[EMAIL PROTECTED]>, est
wrote:
> Well, you succeseded in putting all blame to myself alone. Great.
Take it as a hint.
> When you guy's are dealing with CJK characters in the future, you'll
> find out what I mean.
Speaking as somebody who HAS dealt with CJK characters in the past--se
In article <[EMAIL PROTECTED]>,
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> from random import randint
> ''.join(chr(randint(0, 255)) for i in xrange(len(input)))
>
>
> of course. How else should you get random bytes? :)
That a UUOL (Useless Usage Of Len; by analogy to UUOC). This works just
Steven D'Aprano wrote:
str(b'123') # b prefix is added
"b'123'"
Perhaps I'm misinterpreting it, but from here it looks to me that str()
is doing what repr() used to do, and I'm really not sure that's a good
thing. I would have expected that str(b'123') in Python 3 should do the
same thing a
On Sep 28, 7:12 pm, Lie <[EMAIL PROTECTED]> wrote:
> On Sep 28, 3:35 pm, est <[EMAIL PROTECTED]> wrote:
>
> > > Because that's how ASCII is defined.
> > > Because that's how ASCII is defined. ASCII is a 7-bit code.
>
> > Then why can't python use another default encoding internally
> > range(256)?
On Sep 28, 3:35 pm, est <[EMAIL PROTECTED]> wrote:
> > Because that's how ASCII is defined.
> > Because that's how ASCII is defined. ASCII is a 7-bit code.
>
> Then why can't python use another default encoding internally
> range(256)?
>
> > Python refuses to guess and tries the lowest common deno
On Sep 28, 6:15 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Sun, 28 Sep 2008 01:35:11 -0700, est wrote:
> >> Because that's how ASCII is defined.
> >> Because that's how ASCII is defined. ASCII is a 7-bit code.
>
> > Then why can't python use another default encoding internally
>
On Sep 28, 4:21 pm, est <[EMAIL PROTECTED]> wrote:
> On Sep 28, 4:38 pm, Steven D'Aprano <[EMAIL PROTECTED]
>
>
>
> cybersource.com.au> wrote:
> > On Sat, 27 Sep 2008 22:37:09 -0700, est wrote:
> > str(u'\ue863')
> > > Traceback (most recent call last):
> > > File "", line 1, in
> > > Unico
On Sun, 28 Sep 2008 01:35:11 -0700, est wrote:
>> Because that's how ASCII is defined.
>> Because that's how ASCII is defined. ASCII is a 7-bit code.
>
> Then why can't python use another default encoding internally
> range(256)?
Because that doesn't suffice. Unicode code points can be >255.
On Sep 28, 11:21 am, est <[EMAIL PROTECTED]> wrote:
> On Sep 28, 4:38 pm, Steven D'Aprano <[EMAIL PROTECTED]
> Can anyone tell me how to customize a default encoding, let's say
> 'ansi' which handles range(256) ?
I assume you are using python2.5
Edit the file /usr/lib/python2.5/site.py
There is a
On Sep 28, 12:37 pm, est <[EMAIL PROTECTED]> wrote:
> From python manual
>
> str( [object])
>
> Return a string containing a nicely printable representation of an
> object. For strings, this returns the string itself. The difference
> with repr(object) is that str(object) does not always attempt to
On Sep 28, 4:38 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Sat, 27 Sep 2008 22:37:09 -0700, est wrote:
> str(u'\ue863')
> > Traceback (most recent call last):
> > File "", line 1, in
> > UnicodeEncodeError: 'ascii' codec can't encode character u'\ue863' in
> > po
On Sat, 27 Sep 2008 22:37:09 -0700, est wrote:
str(u'\ue863')
> Traceback (most recent call last):
> File "", line 1, in
> UnicodeEncodeError: 'ascii' codec can't encode character u'\ue863' in
> position 0
> : ordinal not in range(128)
>
> FAIL.
What result did you expect?
[...]
> The
> Because that's how ASCII is defined.
> Because that's how ASCII is defined. ASCII is a 7-bit code.
Then why can't python use another default encoding internally
range(256)?
> Python refuses to guess and tries the lowest common denominator -- ASCII --
> instead.
That's the problem. ASCII is I
On Sun, 28 Sep 2008 03:55:46 -0400, Terry Reedy wrote:
> est wrote:
>>>From python manual
>>
>> str( [object])
>>
>> Return a string containing a nicely printable representation of an
>> object. For strings, this returns the string itself. The difference
>> with repr(object) is that str(object)
On Sun, 28 Sep 2008 19:03:42 +1300, Lawrence D'Oliveiro wrote:
> In message
> <[EMAIL PROTECTED]>, est
> wrote:
>
>> The problem is, why the f**k set ASCII encoding to range(128)
>
> Because that's how ASCII is defined.
>
>> while str() is internally byte array it should be handled in
est wrote:
>>From python manual
>
> str( [object])
>
> Return a string containing a nicely printable representation of an
> object. For strings, this returns the string itself. The difference
> with repr(object) is that str(object) does not always attempt to
> return a string that is acceptable t
On Sat, 27 Sep 2008 22:37:09 -0700, est wrote:
> The problem is, why the f**k set ASCII encoding to range(128)
Because that's how ASCII is defined. ASCII is a 7-bit code.
> while str() is internally byte array it should be handled in range(256)
> !!
Yes `str` can handle that,
In message
<[EMAIL PROTECTED]>, est
wrote:
> The problem is, why the f**k set ASCII encoding to range(128)
Because that's how ASCII is defined.
> while str() is internally byte array it should be handled in
> range(256) !!
But that's for random bytes. How would you convert an a
>From python manual
str( [object])
Return a string containing a nicely printable representation of an
object. For strings, this returns the string itself. The difference
with repr(object) is that str(object) does not always attempt to
return a string that is acceptable to eval(); its goal is to r
20 matches
Mail list logo