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


Groups > comp.lang.python > #30532

Re: Compairing filenames in a list

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.021
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'item.': 0.07; 'python': 0.09; 'basename': 0.09; 'filenames,': 0.09; 'sure,': 0.09; 'cc:addr:python-list': 0.10; 'extensions,': 0.16; 'wrote:': 0.17; 'code,': 0.18; 'work,': 0.22; 'cc:2**0': 0.23; 'kevin': 0.23; 'split': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.28; 'subject:list': 0.28; 'key,': 0.29; 'anyone': 0.33; 'version': 0.34; 'list': 0.35; 'pm,': 0.35; 'does': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'easy': 0.60; 'different': 0.63; 'show': 0.63; 'header:Reply- To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72
Date Sat, 29 Sep 2012 21:41:03 -0400
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0
MIME-Version 1.0
To Kevin Anthony <kevin.s.anthony@gmail.com>
Subject Re: Compairing filenames in a list
References <CA+C4C6dUQT7v0Eyhgsf9Mx+mh9YXYRRBOQObHH7vLJT4FfPF4w@mail.gmail.com>
In-Reply-To <CA+C4C6dUQT7v0Eyhgsf9Mx+mh9YXYRRBOQObHH7vLJT4FfPF4w@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:GUFY183Ovh/CsXMpR4sVs/Z14sZTU8QUhq9pIU+lpLz 22Q5gSFNwboe5zeY4mBBsIso3Deg33Os16rbkZUtJacPkiQ+Ry kVJ0R9OimMye/G3aEWwBUm3vgcw9JVyM+wGHuwWlPSekhGrmgf jnFJRbowNstdRQDv4eSUQYJSU6jBnr4Zf5JX2gWZH0y+cKbZS/ c4/Qlx2CEmiJW0SOfSzyVzSoba3e14lNZElaX3hVjw4SrdXhtO zPUJsHyIlGgoENi+3CECpklNtphf30ygdoP543JjoXC3Vtd4l7 gCoqvCbM9XYn62lvSRCMqPf2ACYpAkSqWTjbwa3YE8oIkyS9A= =
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1659.1348969290.27098.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348969290 news.xs4all.nl 6858 [2001:888:2000:d::a6]:57073
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30532

Show key headers only | View raw


On 09/29/2012 09:27 PM, Kevin Anthony wrote:
> I have a list of filenames, and i need to find files with the same
> name, different extensions, and split that into tuples.  does anyone have
> any suggestions on an easy way to do this that isn't O(n^2)?
>
>

Sure, collect them in a collections.defaultdict  Use basename for the
key, and a list of names as the data item.

if that's not good enough, show us your code, and why it doesn't work,
and tell us what version of Python you're using.

-- 

DaveA

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


Thread

Re: Compairing filenames in a list Dave Angel <d@davea.name> - 2012-09-29 21:41 -0400

csiph-web