Skip to content

Instantly share code, notes, and snippets.

Created October 13, 2013 00:22
Show Gist options
  • Save anonymous/fa367ff6955b10ae6e11 to your computer and use it in GitHub Desktop.
Save anonymous/fa367ff6955b10ae6e11 to your computer and use it in GitHub Desktop.
class entry(object):
"""
This creates a new Type called an entry
"""
__slots__ = ('name', 'gender', 'rank')
def mkEntry(name, gender, rank):
"""
This makes the Entry and reads what is inside it, assigning it
to a variable
"""
ent= entry()
ent.name = name
ent.gender = gender
ent.rank = rank
return ent
def main():
lst = []
year = input('Enter Year: ')
inputFile= open('names/yob' + year + '.txt')
flst = []
mlst = []
for line in inputFile:
line = line.strip().split(',')
name = mkEntry(line[0], line[1], line[2])
lst.append(name)
if name.gender == 'F':
flst +=[line]
else:
mlst +=[line]
while len(lst) > 20:
male = mLst.pop()
female = flst.pop()
if mlst.rank > flst.rank:
lst += [male]
"""
All this is doing is displaying the location of the file not the list
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment