list problem
Simon Forman
rogue_pedro at yahoo.com
Wed Jul 26 11:08:27 EDT 2006
placid wrote:
>
> But there may be other characters before XXX (which XXX is constant). A
> better example would be, that string s is like a file name and the
> characters before it are the absolute path, where the strings in the
> first list can have a different absolute path then the second list
> entries. But the filenames are always exact. So you need to split the
> entries bases on "\\" (windows machine) and match on this ?
>
>
> Cheers
If you're actually working with filenames and paths then you should use
os.path.basename() to get just the filename parts of the paths.
test = set(map(os.path.basename, list1))
test |= set(map(os.path.basename, list2))
(Note: I *was* being stupid last night, the + operator doesn't work for
sets. You want to use | )
Peace,
~Simon
More information about the Python-list
mailing list