Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'item.': 0.07; 'performs': 0.07; 'predefined': 0.07; 'iterate': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; 'files.': 0.13; 'filelist': 0.16; 'iterator': 0.16; 'organise': 0.16; 'set,': 0.16; 'implementing': 0.18; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; 'sets': 0.23; 'header:In-Reply-To:1': 0.24; 'written': 0.24; 'sort': 0.25; 'question': 0.26; 'define': 0.27; 'message-id:@mail.gmail.com': 0.28; 'protocol.': 0.29; 'url:mailman': 0.31; 'certain': 0.31; 'skip:[ 10': 0.32; 'structure': 0.32; 'url:python': 0.33; 'subject:use': 0.33; 'utility': 0.33; 'subject:?': 0.34; 'file': 0.34; 'add': 0.34; 'received:google.com': 0.34; 'that,': 0.34; 'url:listinfo': 0.35; 'could': 0.35; 'files,': 0.35; 'path': 0.35; 'really': 0.35; 'list': 0.35; 'url:org': 0.36; 'list,': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'files': 0.38; 'data': 0.40; 'some': 0.40; 'more': 0.62; 'here': 0.66; 'outline': 0.66; 'skip:\xe2 10': 0.70; 'sets,': 0.84; '8bit%:33': 0.91 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:to :cc:content-type:content-transfer-encoding; bh=k3AdzOFxG4ut9PBHLvHH9OaCQNiaixCu1HDcDZ418UA=; b=R4UXcaJfksmXe1Lme8Mt46jmyQg1AhstutIi6QauuYsXnHOA+MM1YWLHoYlgxqo4Mj SG2Y2x8PidezsaqIdctyxow91ApEFa0ZtqU3AI4E7cgmhH1MYPzmKFzqRL6s23WXiAzm RWKC20+SZzNOAIZZC0V2dxIy7DgziJN4xpflNVkpzJr4wG6HdZtcYQ3n8ZHW627PM2Ny /bmbokWl2K7W0x+fRq3JKD1aCfzYbyWyk5pelwQpnY7luYP/V27so03ig9aT2vhmKEe8 pQtuLD5DeqkJbLDowpZqZd3gkV9Jmc0izYQCbcHglxqhCmKiZuo84LjoEzaXuZF+XQJS mWXw== MIME-Version: 1.0 X-Received: by 10.180.76.208 with SMTP id m16mr20329479wiw.39.1433323499319; Wed, 03 Jun 2015 02:24:59 -0700 (PDT) In-Reply-To: <41302A7145AC054FA7A96CFD03835A0A0B97DECA@EX10MBX02.EU.NEC.COM> References: <41302A7145AC054FA7A96CFD03835A0A0B97DECA@EX10MBX02.EU.NEC.COM> Date: Wed, 3 Jun 2015 11:24:59 +0200 Subject: Re: What sort of data structure to use? From: David Palao To: David Aldrich Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 69 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433323505 news.xs4all.nl 2969 [2001:888:2000:d::a6]:60094 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91936 2015-06-03 10:19 GMT+02:00 David Aldrich : > 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 =3D =E2=80=98pathA=E2=80=99 > > fileListA =3D [=E2=80=98fileA1.txt=E2=80=99, =E2=80=98fileA2.txt=E2=80=99= ] > > > > # File Set B > > pathB =3D =E2=80=98pathB=E2=80=99 > > fileListB =3D [=E2=80=98fileB1.txt=E2=80=99, =E2=80=98fileB2.txt=E2=80=99= , =E2=80=98fileB3.txt=E2=80=99] > > > > 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, fo= r > each set, there is an arbitrary number of files? > > > > Best regards > > > > David > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > And if you really want to link the path to the list of files, you could define an object FileList (trivially) implementing the iterator protocol.