Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83113
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'filename': 0.09; 'subject:files': 0.09; 'subject:How': 0.10; '-tkc': 0.16; 'dirname': 0.16; 'expression.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'simpson': 0.16; 'subject:remove': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'case.': 0.24; 'subject:/': 0.26; 'header:In- Reply-To:1': 0.27; "doesn't": 0.30; 'file': 0.32; 'regular': 0.32; 'charset:us-ascii': 0.36; 'received:10': 0.37; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'expensive': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'skip:o 30': 0.61; 'sound': 0.68; 'received:108': 0.93 |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-MC-Relay | Neutral |
| X-MailChannels-SenderId | wwwh|x-authuser|tim@thechases.com |
| X-MailChannels-Auth-Id | wwwh |
| X-MC-Loop-Signature | 1420198423678:3992947893 |
| X-MC-Ingress-Time | 1420198423678 |
| Date | Fri, 2 Jan 2015 05:35:52 -0600 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | python-list@python.org |
| Subject | Re: How do I remove/unlink wildcarded files |
| In-Reply-To | <20150102102153.GA89926@cskk.homeip.net> |
| References | <20150102090051.GC22372@arxnet.hu> <20150102102153.GA89926@cskk.homeip.net> |
| X-Mailer | Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AuthUser | tim@thechases.com |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17320.1420198435.18130.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1420198435 news.xs4all.nl 2916 [2001:888:2000:d::a6]:35459 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:83113 |
Show key headers only | View raw
On 2015-01-02 21:21, Cameron Simpson wrote:
> >def unlinkFiles():
> > dirname = "/path/to/dir"
> > for f in os.listdir(dirname):
> > if re.match("^unix*$", f):
> > os.remove(os.path.join(dirname, f))
>
> That is a very expensive way to check the filename in this
> particular case. Consider:
>
> if f.startswith('unix'):
>
> instead of using a regular expression.
And worse, the given re would delete a file named "uni" which doesn't
sound ANYTHING like what the OP wanted :-)
-tkc
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How do I remove/unlink wildcarded files Tim Chase <python.list@tim.thechases.com> - 2015-01-02 05:35 -0600
csiph-web