Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91949
| Path | csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!217.73.144.45.MISMATCH!feeder2.ecngs.de!ecngs!feeder.ecngs.de!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <David.Aldrich@EMEA.NEC.COM> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'skip:[ 20': 0.03; 'performs': 0.07; 'predefined': 0.07; 'iterate': 0.09; 'python': 0.11; 'files.': 0.13; 'question.': 0.13; 'def': 0.14; 'message-----': 0.15; '11:59': 0.16; 'files)': 0.16; 'folder,': 0.16; 'organise': 0.16; 'pairs': 0.16; 'received:85.115': 0.16; 'set,': 0.16; 'to:addr:web.de': 0.16; 'url:mailcontrol': 0.16; 'url:sr': 0.16; 'wrote:': 0.16; 'to:name:python-list@python.org': 0.20; 'to:2**1': 0.22; '2015': 0.23; 'sets': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'written': 0.24; 'sort': 0.25; 'question': 0.26; 'yield': 0.27; 'path,': 0.29; 'use?': 0.29; 'skip:b 40': 0.29; "skip:' 10": 0.30; 'folder': 0.31; 'skip:g 30': 0.31; 'url:mailman': 0.31; "i'd": 0.31; 'header:Received:8': 0.31; 'received:169.254': 0.31; 'certain': 0.31; 'skip:[ 10': 0.32; 'skip:_ 10': 0.32; 'structure': 0.32; 'url:python': 0.33; 'class': 0.33; 'problem': 0.33; 'subject:use': 0.33; 'utility': 0.33; 'subject:?': 0.34; 'file': 0.34; 'add': 0.34; 'skip:- 10': 0.34; 'that,': 0.34; 'received:169': 0.35; 'sent:': 0.35; 'url:listinfo': 0.35; 'could': 0.35; 'to:addr:python-list': 0.35; 'list:': 0.35; 'path': 0.35; 'really': 0.35; 'list': 0.35; 'url:org': 0.36; 'list,': 0.36; 'there': 0.36; 'thanks': 0.36; 'subject:': 0.36; 'email addr:python.org': 0.37; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'skip:v 20': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'data': 0.40; 'some': 0.40; 'received:85': 0.60; 'simple': 0.61; 'spam.': 0.61; 'more': 0.62; 'here': 0.66; 'outline': 0.66; 'python-list': 0.66; 'email name :python-list': 0.67; 'click': 0.77; 'otten': 0.84; 'sets,': 0.84; 'skip:v 50': 0.84 |
| From | David Aldrich <David.Aldrich@EMEA.NEC.COM> |
| To | Peter Otten <__peter__@web.de>, "python-list@python.org" <python-list@python.org> |
| Subject | RE: What sort of data structure to use? |
| Thread-Topic | What sort of data structure to use? |
| Thread-Index | AdCd1fo44gG/MTjASoWMlKddMLloTQAFoBIWAAA3wGA= |
| Date | Wed, 3 Jun 2015 11:07:50 +0000 |
| References | <41302A7145AC054FA7A96CFD03835A0A0B97DECA@EX10MBX02.EU.NEC.COM> <mkmmm3$ott$1@ger.gmane.org> |
| In-Reply-To | <mkmmm3$ott$1@ger.gmane.org> |
| Accept-Language | en-GB, en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| x-originating-ip | [172.29.68.112] |
| Content-Type | text/plain; charset="us-ascii" |
| Content-Transfer-Encoding | quoted-printable |
| MIME-Version | 1.0 |
| X-Scanned-By | MailControl 40197.329 (www.mailcontrol.com) on 10.65.0.125 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.101.1433333945.13271.python-list@python.org> (permalink) |
| Lines | 89 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1433333945 news.xs4all.nl 2952 [2001:888:2000:d::a6]:56902 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:91949 |
Show key headers only | View raw
Thanks very much for all the answers given to my question. They help me to think about the problem pythonically.
Best regards
David
> -----Original Message-----
> From: Python-list [mailto:python-list-
> bounces+david.aldrich=emea.nec.com@python.org] On Behalf Of Peter
> Otten
> Sent: 03 June 2015 11:59
> To: python-list@python.org
> Subject: Re: What sort of data structure to use?
>
> David Aldrich wrote:
>
> > Hi
> >
> > I have written a Python utility that performs a certain activity on
> > some predefined sets of files. Here is the outline of what I have written:
> >
> > # File Set A
> > pathA = 'pathA'
> > fileListA = ['fileA1.txt', 'fileA2.txt']
> >
> > # File Set B
> > pathB = 'pathB'
> > fileListB = ['fileB1.txt', 'fileB2.txt', 'fileB3.txt']
> >
> > myFunc1(pathA, fileListA)
> > myFunc2(pathA, fileListA)
> >
> > myFunc1(pathB, fileListB)
> > myFunc2(pathB, fileListB)
> >
> > I want to add more file sets, so I really want to add the sets to a
> > list and iterate over the list, calling myFunc1 & myFunc2 for each item.
> >
> > My question is: what sort of data structure could I use to organise
> > this, given that I want to associate a set of files with each path and
> > that, for each set, there is an arbitrary number of files?
>
> I'd start simple and put (path, files) pairs into a list:
>
> path_files_pairs = [
> ("pathA", ["fileA1.txt", "fileA2.txt", ...]),
> ("pathB", ["fileB1.txt", ...]),
> ]
>
> for path, files in path_files_pairs:
> func1(path, files)
> func2(path, files)
>
> You can always add complications later:
>
> import glob
> import os
>
> class VirtualFileset:
> def __init__(self, folder, pattern):
> self.folder = folder
> self.pattern = pattern
> def __iter__(self):
> yield self.folder
> yield glob.glob(os.path.join(self.folder, self.pattern))
>
> path_files_pairs = [
> ("pathA", ["fileA1.txt", "fileA2.txt", ...]),
> ("pathB", ["fileB1.txt", ...]),
> VirtualFileset("pathC", "*.py"), # all python files in directory "pathC"
> ]
>
> for path, files in path_files_pairs:
> func1(path, files)
> func2(path, files)
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
> Click
> https://www.mailcontrol.com/sr/51ZWmSF1P47GX2PQPOmvUmaGI8Tu3yGr
> Vrr5Tv1xM3UP2MNyoKSTyt0rIsjE4onM5MUvmWbo6fT3KeH4!zzvzA== to
> report this email as spam.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
RE: What sort of data structure to use? David Aldrich <David.Aldrich@EMEA.NEC.COM> - 2015-06-03 11:07 +0000
csiph-web