Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69589
| References | <f3b4238a-6bf4-478e-9326-1ba239d5237f@googlegroups.com> <533cc967$0$2909$c3e8da3$76491128@news.astraweb.com> <mailman.8825.1396494621.18130.python-list@python.org> <87fvluss86.fsf@elektro.pacujo.net> <1396533471.32018.102326165.14B5BB43@webmail.messagingengine.com> |
|---|---|
| Date | 2014-04-04 01:17 +1100 |
| Subject | Re: Unicode Chars in Windows Path |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8842.1396534649.18130.python-list@python.org> (permalink) |
On Fri, Apr 4, 2014 at 12:57 AM, <random832@fastmail.us> wrote: > An argument [in a position where a list of filenames is expected] with * > or ? in it _always_ gets globbed, so "C:\dir with spaces\*.txt" can be > used. This is part of the reason the program is responsible for globbing > rather than the shell - because only the program knows if it expects a > list of filenames in that position vs a text string for some other > purpose. Which, I might mention, is part of why the old DOS way (still applicable under Windows, but I first met it with MS-DOS) of searching for files was more convenient than it can be with Unix tools. Compare: -- Get info on all .pyc files in a directory -- C:\>dir some_directory\*.pyc $ ls -l some_directory/*.pyc So far, so good. -- Get info on all .pyc files in a directory and all its subdirectories -- C:\>dir some_directory\*.pyc /s $ ls -l `find some_directory -name \*.pyc` Except that the ls version there can't handle names with spaces in them, so you need to faff around with null termination and stuff. With bash, you can use 'shopt -s globstar; ls -l **/*.py', but that's not a default-active option (at least, it's not active on any of the systems I use, but they're all Debians and Ubuntus; it might be active by default on others), and I suspect a lot of people don't even know it exists; I know of it, but don't always think of it, and often end up doing the above flawed version. On the flip side, having the shell handle it does mean you automatically get this on *any* command. You can go and delete all those .pyc files by just changing "ls -l" into "rm" or "dir" into "del", but that's only because del happens to support /s; other DOS programs may well not. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unicode Chars in Windows Path Steve <sreisscruz@gmail.com> - 2014-04-02 16:27 -0700
Re: Unicode Chars in Windows Path Steven D'Aprano <steve@pearwood.info> - 2014-04-03 02:37 +0000
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-03 14:10 +1100
Re: Unicode Chars in Windows Path Marko Rauhamaa <marko@pacujo.net> - 2014-04-03 12:00 +0300
Re: Unicode Chars in Windows Path Peter Otten <__peter__@web.de> - 2014-04-03 15:09 +0200
Re: Unicode Chars in Windows Path random832@fastmail.us - 2014-04-03 09:57 -0400
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-04 01:17 +1100
Re: Unicode Chars in Windows Path David <bouncingcats@gmail.com> - 2014-04-04 11:15 +1100
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-04 12:16 +1100
Re: Unicode Chars in Windows Path David <bouncingcats@gmail.com> - 2014-04-04 13:02 +1100
Re: Unicode Chars in Windows Path Terry Reedy <tjreedy@udel.edu> - 2014-04-03 14:41 -0400
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-04 09:06 +1100
Re: Unicode Chars in Windows Path Lele Gaifax <lele@metapensiero.it> - 2014-04-04 09:07 +0200
Re: Unicode Chars in Windows Path alister <alister.nospam.ware@ntlworld.com> - 2014-04-03 08:35 +0000
csiph-web