Re: Use __repr__ to show the programmer's representation (was: Need help understanding list structure)

2016-05-03 Thread moa47401
quote - (Though to be fair, I don't really know what the actual problem was, so I might provide a different approach with a different goal ) Originally I was trying to understand the exact structure of the list being returned by the gedcom library. It worked as it was, but I wanted to add addit

Re: Need help understanding list structure

2016-05-03 Thread moa47401
I added a __repr__ method at the end of the gedcom library like so: def __repr__(self): """ Format this element as its original string """ result = repr(self.level()) if self.pointer() != "": result += ' ' + self.pointer() result += ' ' + self.tag()

Re: Need help understanding list structure

2016-05-03 Thread moa47401
At the risk of coming across as a complete dunder-head, I think my confusion has to do with the type of data the library returns in the list. Any kind of text or integer list I manually create, doesn't do this. See my questions down below at the end. If I run the following statements on the lis

Re: Need help understanding list structure

2016-05-03 Thread moa47401
Thanks for the replies. I definitely need a better understanding of "" when using Python objects. So far no luck with web searches or my Python books. Could someone point (no pun intended) me to a good resource? Not that it matters, but the reason I got off track is there are pointers within m

Re: Need help understanding list structure

2016-05-02 Thread moa47401
> When Python's "print" statement/function is invoked, it will print the > textual representation of the object according to its class's __str__ or > __repr__ method. That is, the print function prints out whatever text > the class says it should. > > For classes which don't implement a __str__

Need help understanding list structure

2016-05-02 Thread moa47401
I've been using an old text parsing library and have been able to accomplish most of what I wanted to do. But I don't understand the list structure it uses well enough to build additional methods. If I print the list, it has thousands of elements within its brackets separated by commas as I wou