ChrisChia wrote:
dataList = [a, b, c, ...]
where a, b, c are objects of a Class X.
In Class X, it contains self.name and self.number

If i wish to test whether a number (let's say 100) appears in one of
the object, and return that object,
is that only fast way of solving this problem without iterating
through every object to see the number value?

dataList.__contains__ can only check my object instance name...
anyone can solve this in linear complexity?

Put them into a dict where the key is the number and the value is a list
of the objects with that number.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to