He's using the incorrect datatype for ap_list. This is apprently the collection of AP's already seen, and used with this pattern:
ap_list = []
if AP not in ap_list:
ap_list.append(AP)
print AP
It works, but does a linear scan every time. It's better to use a set() in such a case:
ap_seen = set()
if AP not in ap_seen:
ap_seen.add(AP)
print AP
For looking up things, a set (essentially a dict without values) is much quicker than a list. Is this premature optimisation? Perhaps, but using a list for this purpose is also a code smell.
This is still going strong today in list slice notation in Python (and other languages, no doubt):
x = [1,2,5,6]
x[2:2] = [3,4]
print(x)
(Slice notation can be used on any collection, not just lists, but you can't use it in assignment like that for strings because they're immutable, so you'd have to convert to a list of characters and back.)
reply