"spir" <denis.s...@free.fr> wrote
> The current way of reading the data is this:
>
> def get_info(person)
> infoDic = {}
> infoDic['first'] = parser.get(person, 'firstName')
> infoDic['last'] = parser.get(person, 'lastName')
> infoDic['father'] = parser.get(person, 'father')
> infoDic['mother'] = parser.get(person, 'mother')
> return infoDic
TYhis is almost the same but you are using a dict.
A sligtly more readable version is to define a class Person:
class Person:
def __init__(self, parser):
self.first = parser.get(person, 'firstName')
Maybe I don't get the point, but I find it strange to make Person
dependant not only of the data storage format, but also of the
parsing technique.
Yes, its not normal and the class probably should be called
ParsedPerson or somesuch. I ws trying to mimic the current
code style as much as possible, that was the reason for the
decision. Normally I would agree with you and use:
class Person:
def __init__(self, first, last, father, mother):
self.first = first
self.last = last
self.father = father
self.mother = mother
Alan G.
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor