On Sun, 1 May 2022 at 00:03, Vlastimil Brom wrote:
> (Even the redundant u prefix from your python2 sample is apparently
> accepted, maybe for compatibility reasons.)
Yes, for compatibility reasons. It wasn't accepted in Python 3.0, but
3.3 re-added it to make porting easier. It doesn't do anythi
čt 28. 4. 2022 v 13:33 odesílatel Stephen Tucker
napsal:
>
> Hi PythonList Members,
>
> Consider the following log from a run of IDLE:
>
> ==
>
> Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
> on win32
> Type "copyright", "credits" or "license()" for m
On 28/04/2022 14:27, Stephen Tucker wrote:
To Cameron Simpson,
Thanks for your in-depth and helpful reply. I have noted it and will be
giving it close attention when I can.
The main reason why I am still using Python 2.x is that my colleagues are
still using a GIS system that has a Python pro
On 2022-04-28, Stephen Tucker wrote:
> Hi PythonList Members,
>
> Consider the following log from a run of IDLE:
>
>==
>
> Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
> on win32
> Type "copyright", "credits" or "license()" for more information.
p
To Cameron Simpson,
Thanks for your in-depth and helpful reply. I have noted it and will be
giving it close attention when I can.
The main reason why I am still using Python 2.x is that my colleagues are
still using a GIS system that has a Python programmer's interface - and
that interface uses P
On 28Apr2022 12:32, Stephen Tucker wrote:
>Consider the following log from a run of IDLE:
>==
>
>Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
>on win32
>Type "copyright", "credits" or "license()" for more information.
print (u"\u2551")
>║
pri
Hi PythonList Members,
Consider the following log from a run of IDLE:
==
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.
>>> print (u"\u2551")
║
>>> print ([u"\u2551"])
[u'\u2551'
icial way of printing
> unicode strings. I mean, the question is not "how can I print the unicode
> string" but "how the creators of the language suppose me to print the
> unicode string". I couldn't find an answer to this question in docs, so I
> hope somebody
on way of
> printing unicode strings?
Try these:
http://effbot.org/zone/unicode-objects.htm>
http://www.reportlab.com/i18n/python_unicode_tutorial.html>
http://www.amk.ca/python/howto/unicode>
If you want something more official, try the PEP that introduced
Unicode object
ally doing like that saves many problems.
> Especially in Python, where there is one official way to do any elementary
> task. And I just want to know what is the normal, official way of printing
> unicode strings. I mean, the question is not "how can I print the unicode
> string"
k. And I just want to know what is the normal, official way of printing
unicode strings. I mean, the question is not "how can I print the unicode
string" but "how the creators of the language suppose me to print the
unicode string". I couldn't find an answer to this question in
On Sun, 14 Dec 2008 06:48:19 +0100, Piotr Sobolewski wrote:
> Then I tried to do this that way:
> sys.stdout = codecs.getwriter("utf-8")(sys.__stdout__)
> s = u"Stanisław Lem"
> print u
> This works but is even more combersome.
>
> So, my question is: what is the official, recommended Python way?
Hello,
in Python (contrary to Perl, for instance) there is one way to do common
tasks. Could somebody explain me what is the official python way of
printing unicode strings?
I tried to do this such way:
s = u"Stanisław Lem"
print u.encode('utf-8')
This works, but is very
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 25, 6:56 am, 7stud <[EMAIL PROTECTED]> wrote:
> Can anyone tell me why I can print out the individual variables in the
> following code, but when I print them out combined into a single
> string, I get an error?
>
> symbol = u'ibm'
> price = u'4 \xbd' # 4 1/2
>
> print "%s" % symbol
> print
7stud wrote:
> Can anyone tell me why I can print out the individual variables in the
> following code, but when I print them out combined into a single
> string, I get an error?
>
> symbol = u'ibm'
> price = u'4 \xbd' # 4 1/2
>
> print "%s" % symbol
> print "%s" % price.encode("utf-8")
> print
Can anyone tell me why I can print out the individual variables in the
following code, but when I print them out combined into a single
string, I get an error?
symbol = u'ibm'
price = u'4 \xbd' # 4 1/2
print "%s" % symbol
print "%s" % price.encode("utf-8")
print "%s %s" % (symbol, price.encode("
[EMAIL PROTECTED] wrote:
> Learn something every day. I take it "646" is an alias for "ascii" (or vice
> versa)?
Usage of "646" as an alias for ASCII is primarily a Sun invention. When
ASCII became an international standard, its standard number became
ISO/IEC 646:1968. It's not *quite* the same a
In article <[EMAIL PROTECTED]>,
"Serge Orlov" <[EMAIL PROTECTED]> wrote:
> Serge Orlov wrote:
> > Ron Garret wrote:
> > > In article <[EMAIL PROTECTED]>,
> > > "Serge Orlov" <[EMAIL PROTECTED]> wrote:
> > >
> > > > Ron Garret wrote:
> > > > > > > I'm using an OS X terminal to ssh to a Linux mach
In article <[EMAIL PROTECTED]>,
"Serge Orlov" <[EMAIL PROTECTED]> wrote:
> Ron Garret wrote:
> > In article <[EMAIL PROTECTED]>,
> > "Serge Orlov" <[EMAIL PROTECTED]> wrote:
> >
> > > Ron Garret wrote:
> > > > > > I'm using an OS X terminal to ssh to a Linux machine.
> > > > >
> > > > > In theor
[EMAIL PROTECTED] wrote:
> Robert> Because sys.stdout.encoding isn't determined by your Python
> Robert> configuration, but your terminal's.
>
> Learn something every day. I take it "646" is an alias for "ascii" (or vice
> versa)?
>
> % python
> Python 2.4.2 (#1, Feb 23 2006, 12:
[EMAIL PROTECTED] wrote:
> John> Hmm, not that this helps me any :)
>
> import sys
> sys.stdout.encoding
> John> 'cp1252'
>
> Sure it does. You can print Unicode objects which map to cp1252. I assume
> that means you're on Windows or that for some perverse reason you h
John> Hmm, not that this helps me any :)
import sys
sys.stdout.encoding
John> 'cp1252'
Sure it does. You can print Unicode objects which map to cp1252. I assume
that means you're on Windows or that for some perverse reason you have your
Mac's Terminal window set to cp
[EMAIL PROTECTED] wrote:
> Robert> Because sys.stdout.encoding isn't determined by your Python
> Robert> configuration, but your terminal's.
>
> Learn something every day. I take it "646" is an alias for "ascii" (or vice
> versa)?
Hmm, not that this helps me any :)
>>> import sys
>>>
Robert> Because sys.stdout.encoding isn't determined by your Python
Robert> configuration, but your terminal's.
Learn something every day. I take it "646" is an alias for "ascii" (or vice
versa)?
% python
Python 2.4.2 (#1, Feb 23 2006, 12:48:31)
[GCC 3.4.1] on sunos5
Typ
John Salerno wrote:
> AFAIK, I'm all ASCII (at least, I never made explicit changes to the
> default Python install), so how am I able to print out the character?
Because sys.stdout.encoding isn't determined by your Python configuration, but
your terminal's.
--
Robert Kern
"I have come to bel
Fredrik Lundh wrote:
> Ron Garret wrote:
>
> u'\xbd'
>> u'\xbd'
> print _
>> Traceback (most recent call last):
>> File "", line 1, in ?
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in
>> position 0: ordinal not in range(128)
>
> so stdout on your machine is asci
Ron Garret a écrit :
> In article <[EMAIL PROTECTED]>,
> Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>
>> Ron Garret wrote:
>>
>> u'\xbd'
>>> u'\xbd'
>> print _
>>> Traceback (most recent call last):
>>> File "", line 1, in ?
>>> UnicodeEncodeError: 'ascii' codec can't encode character u'\
Serge Orlov wrote:
> Ron Garret wrote:
> > In article <[EMAIL PROTECTED]>,
> > "Serge Orlov" <[EMAIL PROTECTED]> wrote:
> >
> > > Ron Garret wrote:
> > > > > > I'm using an OS X terminal to ssh to a Linux machine.
> > > > >
> > > > > In theory it should work out of the box. OS X terminal should se
Ron Garret wrote:
> In article <[EMAIL PROTECTED]>,
> "Serge Orlov" <[EMAIL PROTECTED]> wrote:
>
> > Ron Garret wrote:
> > > > > I'm using an OS X terminal to ssh to a Linux machine.
> > > >
> > > > In theory it should work out of the box. OS X terminal should set
> > > > enviromental variable LAN
In article <[EMAIL PROTECTED]>,
"Serge Orlov" <[EMAIL PROTECTED]> wrote:
> Ron Garret wrote:
> > > > I'm using an OS X terminal to ssh to a Linux machine.
> > >
> > > In theory it should work out of the box. OS X terminal should set
> > > enviromental variable LANG=en_US.utf-8, then ssh should tr
Ron Garret wrote:
> > > I'm using an OS X terminal to ssh to a Linux machine.
> >
> > In theory it should work out of the box. OS X terminal should set
> > enviromental variable LANG=en_US.utf-8, then ssh should transfer this
> > variable to Linux and python will know that your terminal is utf-8.
>
In article <[EMAIL PROTECTED]>,
"Serge Orlov" <[EMAIL PROTECTED]> wrote:
> Ron Garret wrote:
> > In article <[EMAIL PROTECTED]>,
> > "Serge Orlov" <[EMAIL PROTECTED]> wrote:
> >
> > > Ron Garret wrote:
> > > > In article <[EMAIL PROTECTED]>,
> > > > Robert Kern <[EMAIL PROTECTED]> wrote:
> > >
Ron Garret wrote:
> In article <[EMAIL PROTECTED]>,
> Robert Kern <[EMAIL PROTECTED]> wrote:
>
>>Ron Garret wrote:
>>
>>>I'm using an OS X terminal to ssh to a Linux machine.
>>
>>Click on the "Terminal" menu, then "Window Settings...". Choose "Display"
>>from
>>the combobox. At the bottom you w
Ron Garret wrote:
> In article <[EMAIL PROTECTED]>,
> "Serge Orlov" <[EMAIL PROTECTED]> wrote:
>
> > Ron Garret wrote:
> > > In article <[EMAIL PROTECTED]>,
> > > Robert Kern <[EMAIL PROTECTED]> wrote:
> > >
> > > > Ron Garret wrote:
> > > >
> > > > > I forgot to mention:
> > > > >
> > > > sy
In article <[EMAIL PROTECTED]>,
Robert Kern <[EMAIL PROTECTED]> wrote:
> Ron Garret wrote:
>
> > I'm using an OS X terminal to ssh to a Linux machine.
>
> Click on the "Terminal" menu, then "Window Settings...". Choose "Display"
> from
> the combobox. At the bottom you will see a combobox titl
Ron Garret wrote:
>
> But what about this:
>
> >>> f2=open('foo','w')
> >>> f2.write(u'\xFF')
> Traceback (most recent call last):
> File "", line 1, in ?
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xff' in
> position 0: ordinal not in range(128)
> >>>
>
> That should have nothi
Ron Garret wrote:
> I'm using an OS X terminal to ssh to a Linux machine.
Click on the "Terminal" menu, then "Window Settings...". Choose "Display" from
the combobox. At the bottom you will see a combobox title "Character Set
Encoding". Choose "Unicode (UTF-8)".
> But what about this:
>
f2=
In article <[EMAIL PROTECTED]>,
"Serge Orlov" <[EMAIL PROTECTED]> wrote:
> Ron Garret wrote:
> > In article <[EMAIL PROTECTED]>,
> > Robert Kern <[EMAIL PROTECTED]> wrote:
> >
> > > Ron Garret wrote:
> > >
> > > > I forgot to mention:
> > > >
> > > sys.getdefaultencoding()
> > > >
> > > > 'u
Ron Garret wrote:
> In article <[EMAIL PROTECTED]>,
> Robert Kern <[EMAIL PROTECTED]> wrote:
>
> > Ron Garret wrote:
> >
> > > I forgot to mention:
> > >
> > sys.getdefaultencoding()
> > >
> > > 'utf-8'
> >
> > A) You shouldn't be able to do that.
>
> What can I say? I can.
>
> > B) Don't do
Ron Garret wrote:
> In article <[EMAIL PROTECTED]>,
> Robert Kern <[EMAIL PROTECTED]> wrote:
>
>>Ron Garret wrote:
>>
>>>I forgot to mention:
>>>
>>>
>>sys.getdefaultencoding()
>>>
>>>'utf-8'
>>
>>A) You shouldn't be able to do that.
>
> What can I say? I can.
See B).
>>B) Don't do that.
In article <[EMAIL PROTECTED]>,
Robert Kern <[EMAIL PROTECTED]> wrote:
> Ron Garret wrote:
>
> > I forgot to mention:
> >
> sys.getdefaultencoding()
> >
> > 'utf-8'
>
> A) You shouldn't be able to do that.
What can I say? I can.
> B) Don't do that.
OK. What should I do instead?
> C)
Ron Garret wrote:
> I forgot to mention:
>
sys.getdefaultencoding()
>
> 'utf-8'
A) You shouldn't be able to do that.
B) Don't do that.
C) It's not relevant to the encoding of stdout which determines how unicode
strings get converted to bytes when printing them:
>>> import sys
>>> sys.stdou
In article <[EMAIL PROTECTED]>,
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Ron Garret wrote:
>
> u'\xbd'
> > u'\xbd'
> print _
> > Traceback (most recent call last):
> > File "", line 1, in ?
> > UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in
> > position 0: ord
Ron Garret wrote:
u'\xbd'
> u'\xbd'
print _
> Traceback (most recent call last):
> File "", line 1, in ?
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in
> position 0: ordinal not in range(128)
so stdout on your machine is ascii, and you don't understand why you
Ron Garret wrote:
u'\xbd'
> u'\xbd'
print _
> Traceback (most recent call last):
> File "", line 1, in ?
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in
> position 0: ordinal not in range(128)
Not sure if this really helps you, but:
>>> u'\xbd'
u'\xbd'
>>> pri
>>> u'\xbd'
u'\xbd'
>>> print _
Traceback (most recent call last):
File "", line 1, in ?
UnicodeEncodeError: 'ascii' codec can't encode character u'\xbd' in
position 0: ordinal not in range(128)
>>>
--
http://mail.python.org/mailman/listinfo/python-list
47 matches
Mail list logo