On 19 November 2017 at 12:32, Nick Coghlan <ncogh...@gmail.com> wrote:
> On 19 November 2017 at 12:01, Mikhail V <mikhail...@gmail.com> wrote:
>> Python allows underscore character as a separator in variables.
>> This is better than nothing, still it does not make the look much better.
>>
>> **Proposal**: allow additional separator, namely hyphen character.
>
> Regardless of any potential readability merits, backwards
> compatibility requirements combined with the use of the hyphen
> character as a binary operator prohibit such a change:
>
>     >>> my = variable = 1
>     >>> my-variable
>     0

Ah, sorry - I now see you addressed the basic version of that.

The alternative of "Use a character that computers can distinguish,
but humans can't" isn't an improvement, since it means introducing the
exact kind of ambiguity that Python seeks to avoid by using
indentation for block delimeters (rather than having the computer read
braces, and humans read indentation). The difficulty of reliably
distinguishing backticks from regular single quotes is also the main
reason they're generally discounted from reintroduction for any other
use case after their usage as an alternative to the repr builtin was
dropped in Python 3.0, and it's why Python 3 prohibits mixing tabs and
spaces for indentation by default.

For anyone tempted to suggest "What about multiple underscores
indicating continuation of the variable name?", that's still a
compatibility problem due to the unary minus operator:

    >>> my--variable
    2
    >>> my---variable
    0

Would hyphens in variable names improve readability sometimes?
Potentially, but not enough to live with make binary subtraction
expressions ambiguous (hence the consistency amongst almost all
current text based programming languages on this point).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to