In the announcement for Python-2.3 http://groups.google.com/group/comp....fe25388d?hl=en
it says "raw_input( ): can now return Unicode objects".
But I didn't see anything about this in Andrew Kuchling's
"2.3 What's New", nor does the current python docs for
raw_input() say anything about this. A test on a MS
Windows system with a cp932 (japanese) default locale
shows the object returned by raw_input() is a str() object
containing cp932 encoded text. This remained true even
when I set Python's default encoding to cp932 (in
sitecustomize.p y).
So, does raw_input() ever return unicode objects and if
so, under what conditions? 17 4196
"Stuart McGraw" <sm********@fri izz.RimoovAllZZ s.comwrote:
So, does raw_input() ever return unicode objects and if
so, under what conditions?
It returns unicode if reading from sys.stdin returns unicode.
Unfortunately, I can't tell you how to make sys.stdin return unicode for
use with raw_input. I tried what I thought should work and as you can see
it messed up the buffering on stdin. Does anyone else know how to wrap
sys.stdin so it returns unicode but is still unbuffered?
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright" , "credits" or "license" for more information.
>>import sys, codecs sys.stdin.enc oding
'cp437'
>>sys.stdin = codecs.getreade r(sys.stdin.enc oding)(sys.stdi n) raw_input()
hello world
still going?
^Z
^Z
u'hello world'
>>>
Stuart McGraw schrieb:
So, does raw_input() ever return unicode objects and if
so, under what conditions?
At the moment, it only returns unicode objects when invoked
in the IDLE shell, and only if the character entered cannot
be represented in the locale's charset.
Regards,
Martin
On 10/10/06, "Martin v. Löwis" <ma****@v.loewi s.dewrote:
Stuart McGraw schrieb:
So, does raw_input() ever return unicode objects and if
so, under what conditions?
At the moment, it only returns unicode objects when invoked
in the IDLE shell, and only if the character entered cannot
be represented in the locale's charset.
Why only IDLE? Does urwid or another console UI toolkit avoid this somehow?
-- Theerasak
Theerasak Photha wrote:
>>So, does raw_input() ever return unicode objects and if so, under what conditions?
At the moment, it only returns unicode objects when invoked in the IDLE shell, and only if the character entered cannot be represented in the locale's charset.
Why only IDLE? Does urwid or another console UI toolkit avoid this somehow?
Martin was probably thinking of the standard distribution.
The 2.3 note says that "raw_input( ) *can* return Unicode", not that it
"should" or "must" do it.
</F>
On 10/10/06, Fredrik Lundh <fr*****@python ware.comwrote:
Martin was probably thinking of the standard distribution.
The 2.3 note says that "raw_input( ) *can* return Unicode", not that it
"should" or "must" do it.
Practically speaking, at the heart of the matter: as of Python 2.5
final, does or can raw_input() return Unicode under the appropriate
circumstances, according to user wishes?
(Yes, I would test, but I am presently away from my Linux box with
Python, and can't install it here.)
-- Theerasak
Theerasak Photha wrote:
Practically speaking, at the heart of the matter: as of Python 2.5
final, does or can raw_input() return Unicode under the appropriate
circumstances, according to user wishes?
didn't Martin just answer that question?
</F>
On 10/10/06, Fredrik Lundh <fr*****@python ware.comwrote:
Theerasak Photha wrote:
Practically speaking, at the heart of the matter: as of Python 2.5
final, does or can raw_input() return Unicode under the appropriate
circumstances, according to user wishes?
didn't Martin just answer that question?
*slaps forehead* D'oh!
-- Theerasak
Theerasak Photha schrieb:
>At the moment, it only returns unicode objects when invoked in the IDLE shell, and only if the character entered cannot be represented in the locale's charset.
Why only IDLE? Does urwid or another console UI toolkit avoid this somehow?
I admit I don't know what urwid is; from a shallow description I find
("a console user interface library") I can't see the connection to
raw_input(). How would raw_input() ever use urwid?
Regards,
Martin
Theerasak Photha schrieb:
>At the moment, it only returns unicode objects when invoked in the IDLE shell, and only if the character entered cannot be represented in the locale's charset.
Why only IDLE? Does urwid or another console UI toolkit avoid this somehow?
I admit I don't know what urwid is; from a shallow description I find
("a console user interface library") I can't see the connection to
raw_input(). How would raw_input() ever use urwid?
Regards,
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Helmut Jarausch |
last post by:
Hi,
what does Python do if two objects aren't comparable (to my opinion)
If I've understood "Python in a Nutschell" correctly it should raise an
exception but it doesn't do for me.
Here are two examples
if 2 > '1' : print "greater"
else : print "less_or_equal"
|
by: Fred Pacquier |
last post by:
First off, sorry for this message-in-a-bottle-like post... I haven't been
able to phrase my questions well enough to get a meaningful answer from
Google in my research. OTOH, it is standard flattery (but true) that this
group has a bunch of the nicest and most knowledgeable Usenet people
around, and I know for a fact that there are some pretty good spam-
related tools written in Python, so I thought I might get away with it
:-)
Yes,...
|
by: foo |
last post by:
"An unhandled exception of type 'System.NullReferenceException' occurred in
Project.exe
Additional information: Object reference not set to an instance of an
object."
This worked in ver 6, but in VB dot net it abends at the call to
GetComputerName( )...
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA"
|
by: planetthoughtful |
last post by:
Hi All,
As always, my posts come with a 'Warning: Newbie lies ahead!'
disclaimer...
I'm wondering if it's possible, using raw_input(), to provide a
'default' value with the prompt?
I would like to include the ability to edit an existing value (drawn
from an SQLite table) using a DOS console Python app, but my gut
|
by: tim |
last post by:
I want to write a program that looks into a given folder, groups files
that have a certain part of the filename in common and then copy those
groups one at a time to another place, using the raw_input prompt to
continue or break.
here's what I have:
###########
def makegroepen():
global p
| |
by: =?Utf-8?B?QWxleCBLLg==?= |
last post by:
Hi all
My TreeView has unicode and english labels. The treeview shows OK on the
screen.
When I am trying to get an item's label using TVM_GETITEM API message, the
buffer returned by SendMessage always contains single-byte coded labels
(ASCII) even though I use SendMessageW entry point. In other words, buffer is
unicode string each character of which contains two ASCII letters of
corresponding label.
|
by: Dox33 |
last post by:
I ran into a very strange behaviour of raw_input().
I hope somebody can tell me how to fix this.
(Or is this a problem in the python source?)
I will explain the problem by using 3 examples. (Sorry, long email)
The first two examples are behaving normal, the thirth is
strange.......
I wrote the following flabbergasting code:
#-------------------------------------------------------------
|
by: Nathan Pinno |
last post by:
Why does my compiler say invalid syntax and then highlight the
quotation marks in the following code:
# This program is to find primes.
primes =
import math
import gmpy
while 1:
run = int(raw_input("Do you want to calculate primes? 1 = yes and
2 = no. "))
|
by: TP |
last post by:
Hi everybody,
When using raw_input(), the input of the user ends when he types Return on
his keyboard.
How can I change this behavior, so that another action is needed to stop the
input? For example, CTRL-G. It would allow the user to input several lines.
Thanks
Julien
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |