Hi !
If Python is Ok with Unicode, why the next script not run ?
# -*- coding: utf-8 -*-
def режим(toto ):
return(toto*3)
aret = режим(4)
@-salutations
--
Michel Claveau 23 2121
It doesn't work because Python scripts
must be in ASCII except for the
contents of string literals. Having a function
name in anything but ASCII isn't
supported.
John Roth
"Michel Claveau - abstraction méta-galactique non triviale en fuite
perpétuelle." <un************ @msupprimerlepo int.claveauPOIN Tcom> wrote in
message news:41******** **************@ news.wanadoo.fr ...
Hi !
If Python is Ok with Unicode, why the next script not run ?
# -*- coding: utf-8 -*-
def режим(toto ):
return(toto*3)
aret = режим(4)
@-salutations
--
Michel Claveau
John Roth wrote: It doesn't work because Python scripts must be in ASCII except for the contents of string literals. Having a function name in anything but ASCII isn't supported.
To nit-pick a bit, identifiers can be in Unicode; they're simply
confined to digits and plain Latin letters.
Hi ! and plain Latin letters
But not all letters (no : é à ç à ê ö ñ etc.)
Therefore, the Python's support of Unicode is... limited.
Good night
--
Michel Claveau
"Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle." <un************ @msupprimerlepo int.claveaupoin tcom> wrote: Hi !
and plain Latin letters
But not all letters (no : é Ã* ç Ã* ê ö ñ etc.)
.... and some more letters that are not latin (j,w,u,z)
ok, I'd better shut up :-)
--
-----------------------------------------------------------
| Radovan GarabÃ*k http://melkor.dnp.fmph.uniba.sk/~garabik/ |
| __..--^^^--..__ garabik @ kassiopeia.juls .savba.sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
Uhm ... class C(object):
.... pass
.... setattr(C, "è", "The letter è") getattr(C, "è")
'The letter \xe8'
;-)
Michele Simionato
I forgot to add the following: setattr(C, "è", u"The letter è") getattr(C, "è")
u'The letter \xe8' print getattr(C, "è")
The letter è
Python identifiers can be generic strings, including Latin-1
characters;
they cannot be unicode strings, however:
setattr(C, u"è", "The letter è")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeEncodeEr ror: 'ascii' codec can't encode character u'\xe8' in
position 0: ordinal not in range(128)
So you are right after all, but I though most people didn't know that
you can have
valid identifiers with accented letters, spaces, and non printable
chars.
setattr(C, " ", "this works") getattr(C, " ")
Michele Simionato
Michel Claveau - abstraction méta-galactique non triviale en fuite
perpétuelle. wrote: Hi !
If Python is Ok with Unicode, why the next script not run ?
# -*- coding: utf-8 -*-
def режим(toto ): return(toto*3)
Because the coding is only supported in string literals.
But I'm not sure exactly why. It would be nice to do:
import math
Ï€ = math.pi
--
Pádraig Brady - http://www.pixelbeat.org
-- mi************* **@gmail.com wrote: I forgot to add the following:
setattr(C , "è", u"The letter è") getattr(C , "è") u'The letter \xe8' print getattr(C, "è") The letter è
But try this: C.è
File "<stdin>", line 1
C.è
^
SyntaxError: invalid syntax Python identifiers can be generic strings, including Latin-1 characters;
I don't think so. You have hacked an attribute with latin-1 characters in it, but you haven't
actually created an identifier.
According to the language reference, identifiers can only contain letters a-z and A-Z, digits 0-9
and underscore. http://docs.python.org/ref/identifiers.html
Kent
Michel Claveau - abstraction méta-galactique non triviale en fuite
perpétuelle. wrote: Hi !
and plain Latin letters
But not all letters (no : é à ç à ê ö ñ etc.) Therefore, the Python's support of Unicode is... limited.
So is the support of Unicode in virtually every computer language
because they don't support ... digits except 0..9. Does anyone know a
language that supports?
Serge. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jonathon Blake |
last post by:
All:
Question
Python is currently Unicode Compliant.
What happens when strings are read in from text files that were
created using GB 2312-1980, or KPS 9566-2003, or other, equally
obscure code ranges?
|
by: PyDenis |
last post by:
Today, I found strange error while using py2exe:
1. I wrote simple program and save as 1.py:
import win32ui
import win32con
win32ui.MessageBox('Test messageBox.' , 'Test', win32con.MB_OK |
win32con.MB_TOPMOST )
2. I create 1_setup.py file for py2exe:
|
by: KvS |
last post by:
Hi all,
I've been reading about unicode in general and using it in Python in
particular lately as this turns out to be not so straightforward
actually. I wanted to aks two questions:
1) I'm writing a program that interacts with the user through wxPython
(unicode build) and stores & retrieves data using PySQLite. As fas as I
know now, both packages are capable of handling Python unicode objects
(wxPython returns the values of text...
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 431 open ( +3) / 3425 closed ( +8) / 3856 total (+11)
Bugs : 916 open (-23) / 6273 closed (+44) / 7189 total (+21)
RFE : 244 open ( +4) / 240 closed ( +1) / 484 total ( +5)
New / Reopened Patches
______________________
|
by: bsagert |
last post by:
Some web feeds use decimal character entities that seem to confuse
Python (or me). For example, the string "doesn't" may be coded as
"doesn’t" which should produce a right leaning apostrophe.
Python hates decimal entities beyond 128 so it chokes unless you do
something like string.encode('utf-8'). Even then, what should have
been a right-leaning apostrophe ends up as "’". The following script
does just that. Look for the string "The...
| |
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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...
| |