Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Windows': 0.02; '(at': 0.04; 'argument': 0.05; 'purpose.': 0.07; 'string': 0.09; 'filenames': 0.09; 'spaces': 0.09; 'used.': 0.09; 'windows,': 0.09; 'cc:addr:python-list': 0.11; '*any*': 0.16; '12:57': 0.16; 'bash,': 0.16; 'command.': 0.16; 'expects': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'stuff.': 0.16; 'subject:Unicode': 0.16; 'which,': 0.16; 'wrote:': 0.18; 'version.': 0.19; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'convenient': 0.24; 'cc:2**0': 0.24; 'gets': 0.27; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'unix': 0.29; 'dos': 0.30; 'message-id:@mail.gmail.com': 0.30; 'option': 0.32; 'text': 0.33; 'fri,': 0.33; 'not.': 0.33; "can't": 0.35; 'info': 0.35; 'except': 0.35; 'knows': 0.35; 'good.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'doing': 0.36; 'responsible': 0.36; 'changing': 0.37; 'searching': 0.37; 'list': 0.37; 'handle': 0.38; 'files': 0.38; 'rather': 0.38; 'does': 0.39; 'delete': 0.39; 'even': 0.60; 'applicable': 0.60; 'first': 0.61; 'more': 0.64; 'default': 0.69; '(still': 0.84; 'compare:': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=fRqxBaRaxVZzVyb2qJQtOYihK6Uj1rF4/YjqothUNc4=; b=E7ny4qJw+5sS/GhHmbVMBzxjiJ3DeeFsFXlww778HloxJUlqry+ke3P9O5C7CxVucq 3zKraKqwf8JukVXWmvGs8jybr3JyoGlFr5l4aOkcoj4N/Y0yan3T64w/tpLPIsKjmpCs j8MrUj6qCZLMP7Hf2UUfCPfrcnuJwJyk3l99grbYOz74ktwKWa3fNkIDhHhKpuFgERyM RaGD9G7cfuREIsiDZF4ZX70oKeIwT+uIMAbSoUgUYnnbtKkyee4X4bqwfUV/ZXdoUu1r DeNkthbx3U7ZM+bEzVOjjUioch8bJswXiMDEIFDvY1NlOMHkd9RXEqVNjGY081lnqgDQ uXmA== MIME-Version: 1.0 X-Received: by 10.68.112.164 with SMTP id ir4mr7545411pbb.153.1396534646012; Thu, 03 Apr 2014 07:17:26 -0700 (PDT) In-Reply-To: <1396533471.32018.102326165.14B5BB43@webmail.messagingengine.com> References: <533cc967$0$2909$c3e8da3$76491128@news.astraweb.com> <87fvluss86.fsf@elektro.pacujo.net> <1396533471.32018.102326165.14B5BB43@webmail.messagingengine.com> Date: Fri, 4 Apr 2014 01:17:25 +1100 Subject: Re: Unicode Chars in Windows Path From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396534649 news.xs4all.nl 2858 [2001:888:2000:d::a6]:50582 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69589 On Fri, Apr 4, 2014 at 12:57 AM, 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