7

I need to write few basic scripts for students in Python, like this one:

#!/usr/bin/python
# -*- coding: utf-8 -*-

mia_età = 31
print mia_età

But apparently I cannot use accented characters while declaring variables. Is there any way out?

("mia_età" means "my_age" in Italian and I would like to avoid them to write grammar errors in their firts language while learning Python)

0

1 Answer 1

12

Python 1 and 2 only support ASCII alphanumeric characters and _ in identifiers.

Python 3 supports all Unicode letters and certain marks in identifiers.

#!/usr/bin/python3
# -*- coding: utf-8 -*-
mia_età = 31
print(mia_età)

Identifiers are normalized according to NFKC, so you can indifferently write U+0061 LATIN SMALL LETTER A followed by U+0301 COMBINING ACUTE ACCENT, or U+00E1 LATIN SMALL LETTER A WITH ACUTE.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.