[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [HTCondor-users] proper way to check fo undefined classAd in python



Stefano (and others):

I am reminded of when I was recommended to use "is" and "is not" when comparing to None in Python:

https://peps.python.org/pep-0008/#programming-recommendations

The same recommendation applies to comparisons with classad.Value.Error and classad.Value.Undefined, which are similar in function to None, but not similar enough that the ClassAd bindings translate them to None.

I realize this doesn't help with backwards compatibility, and I will make a ticket to improve the Python bindings docs to clearly point out the difference between using "=="/"!=" and "is"/"is not" operators.

Jason

On 6/22/22 10:38 AM, Stefano Belforte wrote:
thanks John. I believe that this is correct for classAd language,
but I suspect somehow the bad syntax managed to work inside python bindings up to
HTCondor 8 as indicated in the post mentioned by Jason
 Âhttps://www-auth.cs.wisc.edu/lists/htcondor-users/2021-May/msg00025.shtml
since bot in that and in my case the point is the conversion (or not) to a boolean
inside python of the C++ value.
OTOH, I have no concrete evidence that the code I am trying to fix really worked
in the past, nor am in the mood of installing an older condor version to test.
I am quite happy and confident about what I have now.
Stefano


On 22/06/2022 16:44, John M Knoeller wrote:
!= should never have worked to compare undefined. So if this used to work in the python bindings that was a bug.

Undefined is not like other values, it cannot be compared using == or !=, it can only be compared using the exact equality (is or =?=)Â or exact inequality (isnt or =!=) operators
_______________________________________________
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users

The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/