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


Groups > comp.lang.python > #30532

Re: Compairing filenames in a list

Date 2012-09-29 21:41 -0400
From Dave Angel <d@davea.name>
Subject Re: Compairing filenames in a list
References <CA+C4C6dUQT7v0Eyhgsf9Mx+mh9YXYRRBOQObHH7vLJT4FfPF4w@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1659.1348969290.27098.python-list@python.org> (permalink)

Show all headers | 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