Executing Python code in VCS works using non ASCII characters but I get "syntax error" when I execute generated ".py" file from terminal

Viewed 24

As far as I know, Python should accept NON ASCII characters for variable identifiers (variables names). I usually use my language characters like "Año" for variable names in VSC, and they are correctly interpreted and executed. No problems at all. Result:

1
2

However, if I try to execute from console (konsole Plasma terminal) in same PC where I execute this code inside VCS my just saved Python code, it ends giving an error about using not ASCII characters. In fact, I tried within Python terminal to assign "Año = 1" and ends with error. and I have been surprised that many of the answers given here nevertheless respond that it has worked for them without any problems.

python
Python 2.7.18 (default, Apr 23 2020, 09:27:04) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> Año = 1
  File "<stdin>", line 1
    Año = 1
     ^
SyntaxError: invalid syntax
>>>

So I guess VSC is doing something to my code before send it to Python interpreter.

This is the simple code in Python

Año = 1
Ano = 2
print(Año)
print(Ano)

I even tried adding these code lines to my code, but no difference:

# -*- coding: utf-8 -*-
# encoding=utf-8
# coding=utf-8

Any idea what's happening in my PC (openSUSE Tumbleweed)?

Thank you

0 Answers
Related