Obnoxious postings from Google Groups
steve+comp.lang.python at pearwood.info
Tue Nov 6 06:03:19 CET 2012
On Mon, 05 Nov 2012 17:39:35 +1100, Chris Angelico wrote:
> On Mon, Nov 5, 2012 at 5:10 PM, rusi <rustompmody at gmail.com> wrote:
>> Among people who know me, I am a linux nerd: My sister scolded me
>> yesterday because I put files on her computer without spaces:
> My filenames seldom have spaces in them, but that has nothing to do with
> how I write English. Names are names. They're not essays, they are not
> written as full sentences.
But names are often multiple words and sentence fragments, and for those
you *need* spaces. Or at least an ersatz space, like underscore, which is
ugly and harder to use, but at least makes using command shells easier to
use. But don't be fooled: the fault belongs to the shell, not the space.
The problem is that shells are untyped and treat *everything* as a stream
of text, and therefore cannot distinguish between arguments, variables,
numbers, commands, etc. except by a few simplistic conventions such as:
"The first word on the line is the command."
"If it starts with a dash, it must be a command option."
"Arguments are separated by spaces."
When your data (e.g. filenames) violate those naive assumptions, as they
frequently do, the shell cannot cope. One solution would be to fix the
tools. Another would be to mangle the data.
"Real" programming languages don't have this problem. You can trivially
refer to any file name, regardless of the characters in its name, in
Python because you have a much more powerful set of tools: commands take
real arguments, and the presence of a space in one argument cannot cause
it to "bleed over" into the next argument.
The downside is that if spaces are not argument separators, then you need
something else to be an argument separator. Or you need argument
delimiters. Or strings need to be quoted. Programming languages do these
things because they are designed to be correct. Shell do not because they
are designed for lazy users and merely aim to be "good enough".
More information about the Python-list