Ask Your Question

Why does'nt "is none" work in python for Calc?

asked 2018-08-24 10:37:36 +0100

PeterB gravatar image

updated 2018-08-24 10:38:26 +0100

Per the PEP 8 Style Guide, the preferred way to compare something to None is the pattern if Cond is None. This seems not to work with Libreoffice (x64) for windows.

This code works:

    if minValue == None:
            if result < minValue:
                result = minValue

But this does not:

  if minValue is None:
        if result < minValue:
            result = minValue

When running the code in an IDE outside Libreoffice the "is None" code works and the "== None" yields a warning (based on PEP 8) such as: "This inspection highlights comparisons with None. That type of comparisons should always be done with 'is' or 'is not', never the equality operators."

It took me a good while to figure this one out and one of the reasons I post this question is to point the issue out so that some one else might get help if they are stuck.

Anyone knows why LibreOffice Python behaves like this?

Thanks, Peter

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-08-24 14:51:37 +0100

erAck gravatar image

There is no "LibreOffice Python". The Python code is thrown at the Python interpreter installed on your system or in case of Mac or Windows it may be the bundled Python interpreter, which for 6.1 should be 3.5.5 and reside in "C:\Program Files\LibreOffice\program\python.exe" or some such; check which interpreter and version is pulled in in your case, something like

import sys

should give the executable's path.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-08-24 10:37:36 +0100

Seen: 50 times

Last updated: Aug 24 '18