Description: The Python installation is in a subdirectory called "python-core-3.8.8", so I assumed that Python 3.8 is embedded. However, the embedded Python does not support the "f-string" formatting feature introduced with Python 3.6. How to find out which Python grammar actually applies to LO macros? Here is a Python 3.6 string formatting example that does not work with LO embedded Python: state = 'not dead' opinion = f'This bird is {state}' However, this old style code works with LO embedded Python: state = 'not dead' opinion = 'This bird is {}'.format(state) Steps to Reproduce: 1.Put an f-string in a message window (see example above) 2.e.g. f'This bird is {state}' 3.Execute macro Actual Results: Display: This bird is {state} Expected Results: Correct display is: This bird is not dead Reproducible: Always User Profile Reset: No Additional Info: In Eclipse PyDev, the f-string code is marked as error if I set the embedded LO Python interpreter. This means, its grammar seems not to comply with Python version 3.6+
(In reply to peter.88213 from comment #0) > The Python installation is in a subdirectory called "python-core-3.8.8", so > I assumed that Python 3.8 is embedded. > However, the embedded Python does not support the "f-string" formatting > feature introduced with Python 3.6. The 7.1.8 version of LibreOffice (which you specified in the Version field) indeed has python 3.8.8 embedded. > state = 'not dead' > opinion = f'This bird is {state}' This f-string works fine for me with LO 7.1.7 on Windows 10, when directly run in a Windows terminal (cmd.exe): C:\Programs\LibreOffice\7.1.7\program>.\python.exe Python 3.8.8rc1 (default, Oct 27 2021, 21:26:25) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> state = 'not dead' >>> opinion = f'This bird is {state}' >>> print( opinion ) This bird is not dead So something is wrong with either your Eclipse setup or your macro. Please describe your setup in more details and provide a macro example, or rather, seek help in user-support forums and come back when you are sure the problem exists in the LibreOffice program/framework itself instead of your local setup.
Thank you so much for the quick response, Ming Hua. Following your advice, I could verify the Python version number and make sure that f-strings are basically working on the command line. Before filing my bug report, I already tried that, but with C:\Program Files\LibreOffice\program\python-core-3.8.8\bin\python.exe which is not working at all on my system. Please close the issue. I think you are right and the problem might have its source in my eclipse setup. Developing LO macros with eclipse is quite tricky because I haven't found a way to establish the UNO bindings yet. Is there a reference list showing which Python version comes with which LO release?
[Automated Action] NeedInfo-To-Unconfirmed
(In reply to peter.88213 from comment #2) > Please close the issue. I think you are right and the problem might have its > source in my eclipse setup. Developing LO macros with eclipse is quite > tricky because I haven't found a way to establish the UNO bindings yet. There are some information about using an IDE with LibreOffice's python on wiki [1], but nothing about Eclipse. Admittedly the documentation about this area is rather sparse. > Is there a reference list showing which Python version comes with which LO > release? Not that I know of. One can always look into the source code repository and deduce this information from git log, but that's not easy. And it isn't very useful anyway, because (1) it only shows the version of bundled python, which is usually the case for Windows, but many Linux distributions build LibreOffice with system's python and don't bundle it, therefore the python version will just be the distribution's choice for the whole system; and (2) the bundled python is just a subset of the official upstream python and many modules of the standard library are stripped, so it's a bit unreliable to predict which python feature is available just by looking at the bundled python version number. 1. https://wiki.documentfoundation.org/Macros/Python_Design_Guide
Thank you for the information. Keep up the good work.