So Python can have unicode variable names but you can't
"explode" (**myvariable) a dict with unicode keys? WTF?
-Devin 6 2006
Devin wrote:
So Python can have unicode variable names but you can't
"explode" (**myvariable) a dict with unicode keys? WTF?
That works fine for me.
Regards,
Martin
"Martin v. Löwis" wrote:
Devin wrote:
>So Python can have unicode variable names but you can't "explode" (**myvariable) a dict with unicode keys? WTF?
That works fine for me.
The OP probably means
>>def f(a=1): return a
....
>>f(**{"a": 42})
42
>>f(**{u"a": 42})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() keywords must be strings
Peter
On Oct 3, 1:57*pm, Peter Otten <__pete...@web.dewrote:
"Martin v. Löwis" wrote:
Devin wrote:
So Python can have unicode variable names but you can't
"explode" (**myvariable) a dict with unicode keys? WTF?
That works fine for me.
The OP probably means
>def f(a=1): return a
...
>f(**{"a": 42})
42
>f(**{u"a": 42})
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
TypeError: f() keywords must be strings
Peter
Yes, that's exactly what I mean.
Devin wrote:
On Oct 3, 1:57 pm, Peter Otten <__pete...@web.dewrote:
>"Martin v. Löwis" wrote:
>>Devin wrote: So Python can have unicode variable names but you can't "explode" (**myvariable) a dict with unicode keys? WTF? That works fine for me.
The OP probably means
>>>>def f(a=1): return a
...
>>>>f(**{"a": 42})
42
>>>>f(**{u"a": 42})
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: f() keywords must be strings
Peter
Yes, that's exactly what I mean.
Hmm. Why did you say that Python can have unicode variable
names? In the version you are using, it can't. In Python
3.0, it can, but then, you can also use Unicode strings
as keys in **arguments, in Python 3.0.
Regards,
Martin
On Oct 3, 2:29*pm, "Martin v. Löwis" <mar...@v.loewis.dewrote:
Devin wrote:
On Oct 3, 1:57 pm, Peter Otten <__pete...@web.dewrote:
"Martin v. Löwis" wrote: Devin wrote: So Python can have unicode variable names but you can't "explode" (**myvariable) a dict with unicode keys? WTF? That works fine for me.
The OP probably means
>>>def f(a=1): return a
... f(**{"a": 42})
42 f(**{u"a": 42})
Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
TypeError: f() keywords must be strings
Peter
Yes, that's exactly what I mean.
Hmm. Why did you say that Python can have unicode variable
names? In the version you are using, it can't. In Python
3.0, it can, but then, you can also use Unicode strings
as keys in **arguments, in Python 3.0.
Regards,
Martin
Oh. I read somewhere that UTF-8 variable names we're supported. I
thought I even saw a colleague using Kanji.
Oh. I read somewhere that UTF-8 variable names we're supported. I
thought I even saw a colleague using Kanji.
In source code (string literals, comments), surely. Not in variable
names, not in 2.x.
To rephrase Bruno's comment: Python supports UTF-8 as a source encoding.
That doesn't mean that you can use all Unicode characters in all places
of the code.
Regards,
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andy Cunningham |
last post by:
Hi all,
Has anyone seen a problem like this before:
http://80.177.2.28/phpinfo.php
This is a webserver on my home PC, and when viewed from there it looks
fine. However, from computers across...
|
by: Shadow Lynx |
last post by:
Consider this simple HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>...
|
by: Mr. Ken |
last post by:
Left shift by negative numbers, will I get 1/2?
Thanks.
|
by: arnuld |
last post by:
what is the difference between these 2:
char name = "hackers";
char* name = "hackers";
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |