[lxml-dev] [objectify] __setText method not usable from python classes

Stefan Behnel stefan_ml at behnel.de
Wed Feb 21 16:08:16 CET 2007


Hi Holger,

Holger Joukl wrote:
> I've experimented with the ObjectifiedDataElement.__setText method a bit
> and found that it is unusable from within python data elements due to
> Python's name mangling.
> E.g. you can't have s.th. like
> 
>     def _init(self):
>         self.__setText("try this")
> or
>     def _init(self):
>         ObjectifiedDataElement.__setText(self, "try this")
> 
> This results in
> AttributeError: type object 'objectify.ObjectifiedDataElement' has no
> attribute '_DatetimeElement__setText
> 
> Confusingly __setText has no notion of being private when used from the
> outside, you can well do
>>>> objectify.ObjectifiedDataElement.__setText(msg.d, "1900")
>>>>
> 
> Maybe use just a single leading underscore and rename it to _setText?

That's ok with me. After all, we're all adults, right? :)

Applied to the trunk.

Stefan



More information about the lxml-dev mailing list