I have an python object list. for example "all_names" I can retrieve values from that list in this way:
for a in all_names:
print a.name,a.age
My target is to quickly find out if a certain name exist in the list all_names.
so I'm doing it in this way.
all = []
for a in all_names:
all.append(a.name)
if "any_name" in all:
print "Name exit"
else:
print "Not found"
But if size of "all_names" is very huge (ex. if len(all_names) > 100,000), then I think It will not be an efficient way to do the same.
So wanted to know, if is there any more efficient way than this??
Thanks in Adv.
all_namesis a really bad variable name for a list of things which are not namesallis an even worse variable name, since it shadows the builtinall