amandasaurus / gedcompy

Python library to parse and work with GEDCOM (geneology/family tree) files
GNU General Public License v3.0
39 stars 18 forks source link

dunder-getitem and get_list essentially the same #8

Open chrrrisw opened 9 years ago

chrrrisw commented 9 years ago

Hi, my changes to resolve the multiple names issue has essentially made dunder-getitem() and get_list() the same, except that dunder-getitem() returns either a list or a single object depending on the number of child elements. This made the client code in name() more complex as I had to check if a list or Element was returned. The name() method could use get_list() instead and if we were to add, say, a spouses() property, this would use the same mechanism. Or we could remove the get_list() method and always return a list from the dunder-getitem() method. This issue is mainly at the discussion stage - what do you see as the way forward? Cheers, Chris.

amandasaurus commented 9 years ago

Perhaps you're right. Maybe x['FOO'] should always return a list. For things which there should only be one result (e.g. SEX), you can write a custom property (like has been done). Then dunder-getitem would be a low-level data access approach for people familiar with GEDCOM, and we can add pythonic functions/properties for things of which make sense (i.e. hiding the how it is implemented in GEDCOM).