Obnoxious postings from Google Groups

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Nov 5 23:46:11 EST 2012


On Mon, 05 Nov 2012 14:47:47 -0500, Dennis Lee Bieber wrote:

>> Don't most OSes allow non-printing characters in filenames?  VMS and
>> Unix always have.  AFAIK, there are only two characters that can't
>> appear in a Unix filename: '\x00' and '/'.
> 
> 	But can you /enter/ them with common keystrokes on a plain text
> terminal (it's been 35 years, so I don't recall the exact key used for
> the BEL on CP/V -- my mind thinks <ctrl-f> was used)... No cut&paste
> from "character map", no <alt>-3digitsequence...


For most people, that's a pointless restriction. You might as well insist 
that the file name can be typed without using the shift key, or using 
only the left hand of the keyboard. Copy-paste, char map, alt-digits are 
as much a part of the input environment on modern systems as the keyboard.

Nevertheless, I do tend to prefer underscores to spaces, simply because I 
often use naive tools that treat spaces as separators. That is, command 
line shells.

For what it's worth, you can enter any control character in Unix/Linux 
systems with readline in bash using the C-q key combination. Newline 
needs a bit of special treatment: you need to wrap the name in single 
quotes to stop the newline from being interpreted as the end of the 
command.

[steve at ando temp]$ touch 'foo
bar'

To enter the newline, I typed Ctrl-Q to tell bash to treat the next 
character as a literal, and then typed Ctrl-J to get a newline.

[steve at ando temp]$ ls
foo?bar
[steve at ando temp]$ python -c "import os
> for nm in os.listdir('.'): print repr(nm)"
'foo\nbar'



-- 
Steven



More information about the Python-list mailing list