https://bugs.documentfoundation.org/show_bug.cgi?id=161843

--- Comment #2 from Tristin Alexander Schwartze <[email protected]> ---
(In reply to Werner Tietz from comment #1)
> first: Don't do 3. 4. 5. in daily practise! never!! store youre python-code
> to:
> ~/.config/libreoffice/4/user/Scripts/python/…
> 
> youre »asking« twice for »text.Start« so there are 2 pointing to the same,
> you may avoid it by:
> 
> ___________________
> def test(*arg):
>     """
>     This is a test macro.
>     keep sure you have some writer.odt in focus
>     """
>     document = XSCRIPTCONTEXT.getDocument()
>     text_object = document.Text.Start
>     document.Text.End.String = f"{text_object is text_object}"
> __________________
> 
> Also note that object equality is checked with "is" and not with the "=="
> operator, and that you do not have to obtain the reference to the currently
> open document in focus in two different ways!
> 
> I would say: Not a Bug!

Respectfully, I disagree. 

The example given is obviously simplified for testing, but it's not
unreasonable to expect two objects with all identical properties to be equal.
In fact, the distinction between "is" and "==" highlights the problem. We're
not checking if they're the same object - we don't care if they're the same
object. We're checking if they're equal. This problem is persistent throughout
the python api, and forces users to conjure up hacky work-arounds to check
basic things that should be built into the objects' dunder methods. 

Maybe the code's structure/design doesn't directly translate well to python or
something, but it's clear a lot more could be done to make this pythonic and
that could open open up a lot of possibilities for python macros. Of-course, if
the developers aren't interested in addressing the python api, that's fine too,
but it's really not cool to suggest that everything's fine where it obviously
isn't.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to