If you're just doing this for yourself and are not too concerned about efficiency, this should suffice:
from socket import *
if __name__ == '__main__':
target = "localhost"
targetIP = gethostbyname(target)
print 'Starting scan on host ', targetIP
#scan reserved ports
for i in range(20, 1025):
s = socket(AF_INET, SOCK_STREAM)
result = s.connect_ex((targetIP, i))
if(result == 0) :
print 'Port %d: OPEN' % (i,)
s.close()
You could always consult Wikipedia's reserved port list to tell what service a user is most likely running.
Also, if you are interested in efficiency (by means of threading), just post back and I'll give you some more code.