Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64097

Re: Python glob and raw string

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'subject:Python': 0.06; 'fname': 0.09; 'subject:string': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'jan': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'impractical': 0.16; 'path.': 0.16; 'subject:raw': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'file.': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'xml': 0.29; 'message-id:@mail.gmail.com': 0.30; 'file': 0.32; 'class': 0.32; 'stuff': 0.32; 'fri,': 0.33; 'guess': 0.33; 'actual': 0.34; 'skip:_ 10': 0.34; 'skip:s 30': 0.35; 'prepare': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'done': 0.36; 'doing': 0.36; 'too': 0.37; 'skip:o 20': 0.38; 'mine': 0.38; 'even': 0.60; '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=f2PbFQnvTkJ6qy4wgjajvJr02VCKEcVXE4Wvmg0KTUM=; b=xQjGqBd8nKEgYpumQjhI1BxqrK/EragWXw2Uy6o3FAem77RkIJX+yuM+wsWsasNrUI DgUBAe30e/UIBjG/o12CEEU9zuFIN9CWPRB7kqcLN+BIKwCZ36AY4/tZ+j9RUcwQLpSO 1oySlnwDeCrY5yUR1k/Hj4t608S12LLGWHiMrH3+7r88hZBL9WQuE+gjdB1AKyKOAUGf F5OD0SS7J7ZIsOhbEOYCkg9blbjptOhQoxELcejMsOhc9z8tuL4ufrf0ctA1oP679Ka9 l8jndv6vf4u1VQcvliENscjBseiWLlC2Pcak8Z2BorN2e3Zzh18tDyATWQRrC4GzhyEd op3w==
MIME-Version 1.0
X-Received by 10.66.102.39 with SMTP id fl7mr11609104pab.43.1389896387297; Thu, 16 Jan 2014 10:19:47 -0800 (PST)
In-Reply-To <lb97i6$8od$1@ger.gmane.org>
References <6d3dd7d7-6836-4b55-9d1c-9e70e18b66fd@googlegroups.com> <lb97i6$8od$1@ger.gmane.org>
Date Fri, 17 Jan 2014 05:19:47 +1100
Subject Re: Python glob and raw string
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <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.5597.1389896390.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389896390 news.xs4all.nl 2972 [2001:888:2000:d::a6]:34560
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:64097

Show key headers only | View raw


On Fri, Jan 17, 2014 at 5:14 AM, Neil Cerutti <neilc@norwich.edu> wrote:
> class Miner:
>     def __init__(self, archive):
>         # setup goes here; prepare to acquire the data
>         self.descend(os.path.join(archive, '*'))
>
>     def descend(self, path):
>         for fname in glob.glob(os.path.join(path, '*')):
>             if os.path.isdir(fname):
>                 self.descend(fname)
>             else:
>                 self.process(fname)
>
>     def process(self, path):
>         # Do what I want done with an actual file path.
>         # This is where I add to the data.
>
> In your case you might not want to process unless the path also
> looks like an xml file.
>
> mine = Miner('myxmldir')
>
> Hmmm... I might be doing too much in __init__. ;)

Hmm, why is it even a class? :) I guess you elided all the stuff that
makes it impractical to just use a non-class function.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python glob and raw string Xaxa Urtiz <urtizvereaxaxa@gmail.com> - 2014-01-16 08:49 -0800
  Re: Python glob and raw string Xaxa Urtiz <urtizvereaxaxa@gmail.com> - 2014-01-16 10:03 -0800
  Re: Python glob and raw string Neil Cerutti <neilc@norwich.edu> - 2014-01-16 18:14 +0000
    Re: Python glob and raw string Xaxa Urtiz <urtizvereaxaxa@gmail.com> - 2014-01-17 08:45 -0800
      Re: Python glob and raw string Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-17 17:38 +0000
  Re: Python glob and raw string Chris Angelico <rosuav@gmail.com> - 2014-01-17 05:19 +1100
  Re: Python glob and raw string Neil Cerutti <neilc@norwich.edu> - 2014-01-16 18:45 +0000

csiph-web