Re: list index()
- From: aleax@xxxxxxx (Alex Martelli)
- Date: Fri, 31 Aug 2007 08:56:21 -0700
mensanator@xxxxxxx <mensanator@xxxxxxx> wrote:
...
Why wouldn't "the one obvious way" be:
def inAnotB(A, B):
inA = set(os.listdir(A))
inBs = set(os.listdir(B))
return inA.difference(inBs)
If you want a set as the result, that's one possibility (although
possibly a bit wasteful as you're building one more set than necessary);
I read the original request as implying a sorted list result is wanted,
just like os.listdir returns (possibly sorted in case-independent order
depending on the underlying filesystem). There's no real added value in
destroying inA's ordering by making it a set, when the list
comprehension just "naturally keeps" its ordering.
Alex
.
- Follow-Ups:
- Re: list index()
- From: Steve Holden
- Re: list index()
- References:
- list index()
- From: zzbbaadd
- Re: list index()
- From: Carsten Haese
- Re: list index()
- From: zzbbaadd
- Re: list index()
- From: Alex Martelli
- Re: list index()
- From: mensanator@xxxxxxx
- list index()
- Prev by Date: Re: status of Programming by Contract (PEP 316)?
- Next by Date: Re: So what exactly is a complex number?
- Previous by thread: Re: list index()
- Next by thread: Re: list index()
- Index(es):