Unicode in Python

Rustom Mody rustompmody at gmail.com
Wed Apr 23 13:59:13 EDT 2014


On Wednesday, April 23, 2014 1:23:00 PM UTC+5:30, Steven D'Aprano wrote:
> On Tue, 22 Apr 2014 23:57:46 -0700, Rustom Mody wrote:

> > On the other hand when/if a keyboard mapping is defined in which the
> > characters that are commonly needed are available, it is reasonable to
> > expect the ∨,∧ to cost no more than 2 strokes each (ie about as much as
> > an 'A'; slightly more than an 'a'. Which means that '∨' is expected to
> > cost about the same as 'or' and ∧ to cost less than an 'and'

> Oh, a further thought...

> Consider your example:

>     return year%4=0 ∧ (year%100≠0 ∨ year%100 = 0)

> vs

>     return year%4=0 and (year%100!=0 or year%100 = 0)

> [aside: personally I like ≠ and if there was a platform independent way
> to type it in any editor, I'd much prefer it over != or <> ]

> Apart from the memorization problem, which I've already touched on, there
> is the mode problem. Keyboard layouts are modes, and you're swapping
> modes. Every time you swap modes, there is a small mental cost. Think of
> it as an interrupt which has to be caught, pausing the current thought
> and starting a new one. So rather than:

>     char char char char char char char ...

> you have:

>     char char char INTERRUPT
>     char INTERRUPT
>     char char char ...

> which is a heavier cost that it appears from just counting keystrokes. Of
> course, the more experienced you become, the smaller that cost will be,
> but it will never be quite as low as just a "regular" keystroke.

> Normally, when people use multiple keyboards, its because that interrupt
> cost is amortized over a significant amount of typing:

>     INTERRUPT (English layout)
>     paragraph paragraph paragraph paragraph
>     INTERRUPT (Greek layout)
>     paragraph paragraph paragraph
>     INTERRUPT (English again)
>     paragraph ...

> and possibly even lost in the noise of a far greater interrupt, namely
> task-switching from one application to another. So it's manageable. But
> switching layouts for a single character is likely to be far more
> painful, especially for casual users of that layout.

> Based on an extremely generous estimate that I use "lambda" four times in
> 100 lines of code, I might use λ perhaps once in a thousand non-Greek
> characters. Similarly, I might use ∧ or ∨ maybe once per hundred
> characters. That means I'm unlikely to ever get familiar enough with
> those that the cost of two interrupts per use will be negligible.

Its gratifying to see an argument whose framing is cognitive-based!

More on that later.

For now: mode/modeless

Yes most of us prefer the Shift key to the Caps Lock even for stretches of capitals.  So analogously here is a modeless solution

Earlier I found this mode-switching version
$ setxkbmap -option "grp:switch,grp:alt_shift_toggle,grp_led:scroll" -layout "us,gr"
this makes Shift-Alt the mode-switcher

This one on the other hand
$ setxkbmap -layout "us,gr" -option "grp:switch"
will make right-alt behave like 'Greek-Shift'

ie typing
abcdefghijklmnopqrstuvwxyz
with RAlt depressed throughout, produces
αβψδεφγηιξκλμνοπ;ρστθωςχυζ

This makes the a Greek letter's ergonomic cost identical to a capital English
letter's:  For Greek use RAlt the way one uses Shift for English.

Notes:
1. Tried on Debian and Ubuntu -- Recent Ubuntus are rather more ill-mannered in
the way they appropriates keys. Still it works as far as I can see.

2. ';' ?? ie semicolon is produced from 'q'? Whats that semicolon doing there?? But then Greek is -- well -- Greek to me! (As is xkb!)



More information about the Python-list mailing list