
Stefan Behnel wrote: [snip]
I personally prefer "_line" over "line", as this only applies to parsed elements, not all of them, so this is more of a half-working API. Additionally, any additional attribute there goes off the list of children accessible in objectify.
I really don't like _line. The underscore in a strong Python convention indicates "implementation details", and code external to a class should *not* be touching attributes which start with an underscore unless it knows it's going to do something evil. Initial underscores are not meant to indicate half-working APIs or something.
Accessing _line is not evil, it's just not guaranteed to be correct if you manipulate a parsed tree, or create a tree from scratch. This should simply be documented.
(Are we sure it's half-working, anyway? Does libxml2 start counting lines at 0 or at 1? If at 1 then 0 is entirely unambiguous and we may be able to return None instead reliably)
Anyway, to conclude, I think 'line' is just fine - I believe that's a complete API, if only not a great one if we can't distinguish between line 0 and "no line known".
Regards,
Martijn