Skip to content

Instantly share code, notes, and snippets.

@yask123
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yask123/007842da6b3d141bace8 to your computer and use it in GitHub Desktop.
Save yask123/007842da6b3d141bace8 to your computer and use it in GitHub Desktop.
class Student(list):
def __init__(self,a_name,a_age,a_branch,a_pointers):
list.__init__([])
self.name=a_name
self.age=a_age
self.branch=a_branch
self.append(a_pointers)
def top_pointer(self):
return(sorted(self)[0])
get_data(filename):
with open(filename) as f:
data = f.readline()
temp=data.strip().split(',')
return(Student(temp.pop(0),temp.pop(0),temp))
store_data():
"""This method returns the dictionary of instances mapped by student's name """
maps={}
temp1=get_data('test.txt')
maps[temp1.name]=temp1#Cool eh?
return(maps)
for each_student in store_data():#Kid's stuff!
print(store_data()[each_student])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment