Using non-ascii characters as variable names in python 2

Viewed 1758

The following code returns “Error: Invalid Syntax” when reaching the third line:

# -*- coding: utf-8 -*-
print “åäö”
ÅÄÖ = 4

The print statement works fine despite holding non-ascii-characters. The problem seems to be when the non-ascii characters are used as variable names. Doing this in python 3 works perfectly fine, and I’ve understood that this is because python 3 and 2 treats strings differently, but i need to use python 2 for various reasons. I really feel like there should be a very simple solution to this problem, but after hours of googling I have not found it. I would be very grateful if someone could help me out!

[ Note: Being able to write the letters åäö in python 2.7 would be extremely valuable to me, partly because I am fairly new to programming in python and strongly prefer naming my variables and functions in swedish as it makes them much easier to separate from pythons in-built functions. ]

1 Answers
Related