python 2.7.12 on Linux behaving differently than on Windows

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Dec 8 02:24:30 EST 2016


BartC wrote:
> Which means that input of A B* *C will all end up running together so 
> that you have no idea what is what or which file corresponds to which 
> expansion.

So if you intend your program to be used on unix, you
need to design it so that it doesn't depend on such
distinctions.

> Now the problem is to determine whether processed input of U V W X Y Z 
> are intended bona fide inputs, or whether they just happened to result 
> from some random associations with the files in the current directory.

You're entitled to assume that a Unix user using your
program from the shell is reasonably intelligent and at
least moderately familiar with how Unix shells behave.

Such a user will *not* be using unescaped wildcards
unless they *intend* them to be expanded. So you are
not going to get "random associations with the files
in the current directory". That's another imaginary
bogeyman.

> But this is what happens when you have to work to the lowest common 
> denominator.

If you're unwilling to do things differently on different
platforms, then yes, you need to restrict yourself to
their intersection. That's an inescapable fact of logic.

> (I'm in the middle of porting my console editor to Linux. But one 
> problem is that on one Linux, half the key combinations (eg. 
> Shift+Ctrl+B) are not recognised.

If you're reading characters from a tty device in raw
mode (which I assume is what you mean by "console editor")
I'm not aware of *any* Unix system that will let you
distinguish between Ctrl+B and Shift+Ctrl+B that way.
That's because the tty driver delivers ASCII characters,
and there are no separate ASCII codes for shifted control
characters.

> Except that was only two Linuxes; perhaps on others, the keyboard will 
> likely be crippled in some other way.

No, they'll all be the same -- if it has an ASCII code,
you'll be able to get it from a tty device, otherwise you
won't.

> How people manage to do anything on such an OS I've no idea.

Programs that need to be able to distinguish all of the
modifiers are normally implemented as GUI applications,
which get keyboard input a different way.

-- 
Greg


More information about the Python-list mailing list