Timeline for Unicode identifiers in Python?
Current License: CC BY-SA 2.5
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 24, 2017 at 8:13 | comment | added | Arne Babenhauserheide | that’s possible, yes. | |
| Nov 24, 2017 at 5:03 | comment | added | Imperishable Night | @ArneBabenhauserheide Actually I think the fact python only reserves lambda is a feature, not a bug, as you can use λ as an actual variable name then. | |
| Oct 18, 2016 at 15:57 | comment | added | Arne Babenhauserheide |
@viksit return (λ x: N/(σ * (2 * np.π)**.5) * np.e ** (-(x-μ)**2/(2 * σ**2))) looks much clearer to me - and it’s easy to type, because I have these letters on my keyboard (and if you’re german, so should you. See neo-layout.org) — note that this isn’t actually valid python, because python only reserves lambda, but not λ.
|
|
| Jul 8, 2014 at 23:43 | comment | added | Fomite | @ThomasWouters My biggest problem is that "lambda" means something in Python, and is also a very common letter used in my field. It's irksome to have to maintain code where it's got non-standard caps, misspelled, etc. | |
| Jun 19, 2014 at 12:29 | comment | added | Mike DeSimone |
One place where Unicode identifiers will be nice is in iPython Notebook, because you can have variable names that are named the same as the variables they represent. For example, the variable representing a chip's thermal impedance from junction to ambient is θJA, and constantly writing it as THETA_JA makes it harder for non-programmers to read the code.
|
|
| Apr 16, 2010 at 10:32 | comment | added | Thomas Wouters | @Paul: sure, readability is always subjective. The audience is important. Which is why you need to consider the audience more than your own preferences. It's easy if you're always going to be your own entire audience, of course, but frequently things that start out that way end up in a wider distribution, and with a wider set of contributors. | |
| Apr 16, 2010 at 9:49 | comment | added | Manos Dilaverakis | "many people will get cross if they have to edit source files with, for example, identifiers A and Α (latin A and greek capital alpha.)" I know I would. And I'm Greek. | |
| Apr 16, 2010 at 9:31 | comment | added | Paul D. Waite | "That doesn't look any more readable with unicode identifiers to me." — It does look more similar to the equation posted at the top of the question though. If someone was used to reading equations like that, mightn’t they find the symbol-y Python code more readable too? | |
| Apr 15, 2010 at 23:28 | comment | added | Thomas Wouters | That doesn't look any more readable with unicode identifiers to me. | |
| Apr 15, 2010 at 23:21 | comment | added | viksit | Just added an edit for this. Try composing something like, return (lambda x: N/(sigma * (2*numpy.pi)**.5) * numpy.e ** (-(x-mu)**2/(2 * sigma**2))) hehe. | |
| Apr 15, 2010 at 23:10 | comment | added | Thomas Wouters | Sure, there are plenty of cases where symbols are more readable than words. Or where non-ASCII characters express things better. I was mostly commenting on the fact that an identifier consisting of a single sigma isn't really an improvement over the word 'sigma' :) | |
| Apr 15, 2010 at 23:05 | comment | added | Paul D. Waite |
I think readability of words versus symbols depends on context. When I’m reading something mathy, I find symbols (e.g. x + y) more readable than the wordy equivalents you’d get in, say, AppleScript (e.g. add x to y). Symbols are terser, and generally let you get by on shape recognition alone, which I think is easier on the brain than reading. I don’t do enough mathy stuff to have felt the need to add a sigma sign to my code though.
|
|
| Apr 15, 2010 at 22:59 | history | answered | Thomas Wouters | CC BY-SA 2.5 |