Simple - looking for a way to do an element exists check..
Paul Rubin
http
Fri Feb 22 17:03:34 EST 2008
Paul McGuire <ptmcg at austin.rr.com> writes:
> I'm still getting used to 'any' and 'all' as new Python built-ins -
> but they'll do the short-circuiting as well as a for-loop-with-break.
> But I think a set- or dict-based solution will still surpass a list-
> based one for the OP.
I guess I don't understand sufficiently well what the OP is trying to
do. If it's just a matter of checking for and then appending one
record, then using "any" looks like the most straightforward. If the
idea is to collect one representative of each value of element[0], and
if the value is hashable, then yes, a set or dict is the best way to
do it.
More information about the Python-list
mailing list