python 2.7.12 on Linux behaving differently than on Windows

Chris Angelico rosuav at gmail.com
Wed Dec 7 07:39:55 EST 2016


On Wed, Dec 7, 2016 at 10:54 PM, BartC <bc at freeuk.com> wrote:
> But if a program existed that took N filename parameters with the purpose of
> deleting each of them, then it can't tell if they were typed in individually
> (so indicating a stronger intent), or whether a finger slipped on a single
> filename and a "*" was added, in which case it could choose to ask for
> confirmation *if* it saw that this is a wildcard).
>
> 'Globbing' (if that means auto expansion) is taking away choice.

And app globbing takes away choice, too. How would you, with the
Windows 'del' command, remove a single file that has a question mark
in the name? Or are you depending entirely on the fact that Windows
doesn't let you do that? Here's some of my music collection:

$ find Music/ -name *\\?*
Music/BeautyStone2/25: Act III. Change of scene?.ogg
Music/BeautyStone2/08: Act II, Scene 1. No. 13 continued. Philip:"How
say you?".ogg
Music/Seekers/CD2 - 1964-1965/17. What Have They Done To The Rain?.mp3
Music/Seekers/CD4 - Hits. B-sides & 90s/14. When Will The Good Apples Fall?.mp3
Music/BeautyStone1/06: Act I, Scene 1. No. 4. Quartet. Simon:"Who
stands within?".ogg
Music/G&S/Pirates of Penzance/111 What ought we to do, Gentle sisters, say?.mp3
Music/G&S/Pirates of Penzance/MusicOnly/111 What ought we to do,
Gentle sisters, say?.ogg

Note that two of the Beauty Stone tracks include quotes as well as
question marks. How do you identify those? Let's say you want to play
one of these in VLC, and then maybe you decide that the track in
Pirates of Penzance/MusicOnly is slightly mis-cropped, so you rebuild
it from the one in the parent directory. How does that work on
Windows? If you say "it doesn't", then (a) you have taken away choice
on a fundamental level, (b) you have your head in the sand, and (c)
you still haven't solved the problem of percent signs, carets, and so
on, which are perfectly legal in file names, but have meaning to the
shell.

> They can be dangerous with certain commands and programs that accept
> wildcards (which aren't many actually; I don't think any of my programs do).

And that right there is a mark against the Windows model. Your program
has to consciously accept wildcards. Mine (on Unix) just has to accept
file names, and *everything will work*.

> If the default is to have it on, then that's not satisfactory.

One line in your shell initialization script will change that default.

>> If *your* design was paramount, it would be up to each and every
>> application to
>> choose whether or not to support globbing and environment variable
>> expansion,
>> and hard luck if the application I needed to use didn't understand the
>> globs I
>> wanted.
>
>
> How many programs take parameters that specify multiple files and work on
> them together? As I said, I think hardly any of mine do.

Once again, you assume that because YOU PERSONALLY write no programs
that need this feature, the feature ITSELF is a bad thing. Can you not
see the arrogance of that?

> It took me a while to recognise the significance of the "\". In Windows
> that's a path separator.

You call yourself a Python programmer and are surprised to find that
backslash is the escape character? It's a pretty common convention.

> Most open source software seems to be written in C and seems to require
> executing a 20,000 or 30,000-line bash 'configure' script, itself dependent
> on a dozen Unix utilities, before it's possible to build it. Even if the
> resulting product is cross-platform.

Not everything is like that. Here, find the configure scripts in these
projects of mine:

https://github.com/Rosuav/Gypsum
https://github.com/Rosuav/StilleBot
https://github.com/Rosuav/FrozenOST
https://github.com/Rosuav/LetMeKnow
https://github.com/Rosuav/zawinski
https://github.com/Rosuav/full-stack-app
https://github.com/Rosuav/miniature-succotash
https://github.com/Rosuav/Yosemite
https://github.com/Rosuav/Hymns
https://github.com/Rosuav/pike-alsa

I think the longest config file is the Hymns collection, with a
twenty-line makefile. Don't judge all open source on what you see in
Mozilla Thunderbird. :)

ChrisA



More information about the Python-list mailing list