473,499 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Exploding" (**myvariable) a dict with unicode keys

So Python can have unicode variable names but you can't
"explode" (**myvariable) a dict with unicode keys? WTF?

-Devin
Oct 3 '08 #1
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
Oct 3 '08 #2
"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

Oct 3 '08 #3
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.
Oct 3 '08 #4
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
Oct 3 '08 #5
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.
Oct 3 '08 #6
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
Oct 4 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1702
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...
50
5992
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>...
16
2001
by: Mr. Ken | last post by:
Left shift by negative numbers, will I get 1/2? Thanks.
34
2654
by: arnuld | last post by:
what is the difference between these 2: char name = "hackers"; char* name = "hackers";
0
7130
marktang
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,...
0
7007
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...
1
6893
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...
0
7386
tracyyun
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...
1
4918
isladogs
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...
0
3098
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...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.