3 ms·
Consider this Python 3 code extract: HCK = 3 Now, does that identifier consist of three ascii letters, or 3 Cyrillic letters that happen to look the same,
by cabalamat 12y ago
Consider this Python 3 code extract:
HCK = 3
Now, does that identifier consist of three ascii letters, or 3 Cyrillic letters that happen to look the same, or some combination of the two? It's impossible to tell.
In Python 3, identifiers don't identify!
- scrollaway 12y agoConsider any bad code. What does it do? Supporting more than ascii in code is a wonderful, wonderful feature for some countries and opens up Python to people for whom the latin alphabet is as familiar as the [pick a non-latin alphabet you don't understand] is to you. Would I use it? No. Would I work on code that used it? Not in three lifetimes. Do I like that it's there? Hell yes. As the slides were showing, I can write shutil.rmtree("/"). Does that mean rmtree should prevent me from passing "/"?
- cabalamat 12y ago> Supporting more than ascii in code is a wonderful, wonderful feature for some countries and opens up Python to people for whom the latin alphabet is as familiar as the [pick a non-latin alphabet you don't understand] is to you. No it doesn't, because reserved words and all the identifiers in the standard library are still in Latin. It is simply not possibly to write Python code without knowing the Latin alphabet.
- scrollaway 12y agoThere is a difference between learning the 33 keywords and learning and dealing with an entire foreign alphabet. And you would be surprised what "development translators" can come up with. You can write wrapper libraries for, heck, the entire stdlib. Yes, it's stupid; but if you are looking for devs in a country where English is less spoken than French on Saturn, it's actually useful.
- cabalamat 12y ago> There is a difference between learning the 33 keywords and learning and dealing with an entire foreign alphabet. It's 52 letters, that're used everywhere in computing. Are there really large numbers of Python programmers who have difficulty with it? I doubt it. > but if you are looking for devs in a country where English is less spoken than French on Saturn, it's actually useful. Have a look at the most-downloaded Python packages at https://python3wos.appspot.com/ https://python3wos.appspot.com/ . How many of them have documentation in languages other than English?
- scrollaway 12y ago> Are there really large numbers of Python programmers who have difficulty with it? I doubt it. Take a guess why that is, please. I'm not going to do a crappy analogy here, but you can't expect "large numbes of people" to be doing something they have inherent difficulty doing.
- gone35 12y agoThere is a difference between learning the 33 keywords and learning and dealing with an entire foreign alphabet. Perhaps, but notice that in order to merely type in those keywords, you need to use pretty much the entire basic Latin alphabet (except for j, q, v and z) [1]. So I think it's fair to ask how big of a difference it really is. [1] https://docs.python.org/3.0/reference/lexical_analysis.html https://docs.python.org/3.0/reference/lexical_analysis.html
- jl6 12y agoThere are countless examples of where allowing non-ASCII identifiers makes code more readable in non-English languages. For example a Brazilian coder might write país = "Brasil" Without the accent, pais means fathers rather than country. Imagine how constraining it would be to code in a language that disallowed vowels in identifiers (perhaps because it had been designed by Hebrew speakers). That's how most of the world experiences Python 2.
- icebraining 12y agoAs a Portuguese coder myself, I shudder seeing that code. You know how would that be written at my company? country = "Brasil" Code in languages other than English is just painful.
- gone35 12y agoSure: your point feels right logically and politically, but in fact it doesn't quite work that way: for Latin script-based languages like Portuguese, non-ASCII letters are extensions (diacritics or liaisons) of the basic Latin alphabet that are often left out in informal writing (eg by grade students, when texting/chatting, or by "uneducated" speakers) when the context is clear and a romanized phonetic approximation is available. As a result, native speakers are well used to homonymy in daily use, even though it might appear quite confusing to a non-native. So, in practice, ambiguities like the one you point out are more likely than not to be as constraining to Latin script-based programmers as common English homographs like "bank" do.