import re from urllib import urlopen   #init the lists uniqueBanList = [] totalBanList = [] tempList = [] url = 'http://74.63.239.234/banlist.txt' import itertools import operator import os import time permaBannedList = re.findall(r'(\bSTEAM_[0-1]:[0-1]:\d+\b) 0 .*', urlopen('http://74.63.239.234/banlist.txt').read())   # find all people permanently banned and add them to a list     def most_common(L):   # get an iterable of (item, iterable) pairs   SL = sorted((x, i) for i, x in enumerate(L))   # print 'SL:', SL   groups = itertools.groupby(SL, key=operator.itemgetter(0))   # auxiliary function to get "quality" for an item   def _auxfun(g):     item, iterable = g       # set these variables to the input to _auxfun()     count = 0       # reset the count variable for each person     five = 5       # yes, this was unneccessary, I know     min_index = len(L)     for _, where in iterable:       count += 1         # for each ban found, add one to the count we're keeping       min_index = min(min_index, where)       if _ in permaBannedList:           # if the person we're checking is permabanned, say so damnit         permabanned = 'yes'       else:           # but we want to make sure these motherfuckers with a shitton of bans           # and no perma get caught           # so if they aren't permabanned, make sure that it says they're not permabanned         permabanned = 'no'     if count >= five:       #if they have more than five bans         tempList.append('%r has been banned %r times. Permabanned: %r.' % (item, count, permabanned)                 open('banlist_mostbanned'+time.strftime('_%I-%M%p_%m_%d_%y')+'.txt', 'a+').write('%r has been banned %r times. Permabanned: %r.\n' % (item, count, permabanned))     return count, -min_index   # pick the highest-count/earliest item   return max(groups, key=_auxfun)[]   # a function for finding all of the occurences of a regex match def num_groups(regex, url):     webpage = urlopen(url).read()     m = re.findall(regex, webpage)     return m   if __name__ == "__main__":    for i in num_groups(r'(\bSTEAM_[0-1]:[0-1]:\d+\b).*', url):                           # this regex finds the first SteamID on a line                           # and then moves to the next line         totalBanList.append(i)                           # when we find a match, add it to the list         if i not in uniqueBanList: uniqueBanList.append(i)                         # if there is a new SteamID that isn't in the                         # unique ID list, add it to the unique ID list print "There have been "+str(len(totalBanList))+ " total bans and "+str(len(uniqueBanList))+' unique people banned since the beginning of time on Noobonic Plague.\nThere have also been '+str(len(permaBannedList))+' permanent bans.' yes = input(r"Do you want to see the list of most-banned people? 1 for yes, 0 for no. > ") if yes == 1:         print most_common(totalBanList)         c = raw_input("Press enter to close the program.")