Unicode variable names

From Rosetta Code
Revision as of 07:16, 1 July 2011 by rosettacode>Paddy3118 (New draft task and Python solution.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Unicode variable names is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
  1. Describe, and give a pointer to documentation on your languages use of characters beyond those of the ASCII character set in the naming of variables.
  2. Show how to:
  • Set a variable with a name including the 'Δ', (delta character), to 1
  • Increment it
  • Then print its value.

Python

Within the ASCII range (U+0001..U+007F), the valid characters for identifiers are the same as in Python 2.x: the uppercase and lowercase letters A through Z, the underscore _ and, except for the first character, the digits 0 through 9.

Python 3.0 introduces additional characters from outside the ASCII range (see PEP 3131). For these characters, the classification uses the version of the Unicode Character Database as included in the unicodedata module.

Identifiers are unlimited in length. Case is significant.

<lang python>>>> Δx = 0 >>> Δx += 1 >>> Δx 1 >>> </lang>