Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Retrieving an object from a set (http://www.velocityreviews.com/forums/t956946-re-retrieving-an-object-from-a-set.html)

Ian Kelly 01-26-2013 12:26 AM

Re: Retrieving an object from a set
 
On Fri, Jan 25, 2013 at 4:45 PM, MRAB <python@mrabarnett.plus.com> wrote:
> You could first limit the search to only those which it could be:
>
> S & set([y])
>
> A search would be:
>
>>>> f = [m for m in S & set([y]) if m is y][0]
>>>> f is y

> True


But in practice he won't have y, only x. So that would have to be:

>>> f = [m for m in S & set([x]) if m is x][0]
>>> f is y

False

And it turns out that my earlier "intersection" suggestion fails for
the same reason.


All times are GMT. The time now is 10:43 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.