[Python-ideas] Accepting "?" as a valid character for identifiers

Stephen J. Turnbull stephen at xemacs.org
Mon Nov 1 02:05:21 CET 2010

Andre Roberge writes:

 > In some languages (e.g. Scheme, Ruby, etc.), the question mark character (?)
 > is a valid character for identifiers.  I find that using it well can improve
 > readability of programs written in those languages.

As pointed out by others, this won't work well in Python.

There is an established idiom for this in Python.  What in Scheme
would be spelled "PREDICATE?" in Python is spelled "is_PREDICATE".

 > Given that one can legally mimic ? in Python identifiers, and given that the
 > ? symbol is not used for anything in Python, would it be possible to
 > consider allowing the use of ? as a valid character in an identifier?

As Georg points out, it is used for something.  Punctuation is
reserved for use as an operator.  That fact that it's not assigned any
specific meaning today doesn't mean that it's unused.  Of course
exceptions are always possible, but this simply doesn't have a good
enough reason to justify an exception.

In any case, this is covered by the moratorium.  By the time a Python
incorporating this suggestion could appear, your students will all
have graduated and will be working for companies, conforming to style
guides that specify use of the "is_PREDICATE" naming scheme.

More information about the Python-ideas mailing list