Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's up with the all caps TRUE and FALSE ?
#2
Well:
Code:
➤> TRUE
True
➤> dir(TRUE)
['__cmp__', '__doc__', '__init__', '__int__', '__module__', '__nonzero__', '__repr__', '__str__', '_deprecated', '_name', '_suggestion', '_v']
➤> TRUE.__module__
'gimpenums'

And gimpenums.py in all its glory:
Code:
from _gimpenums import *

# This is from pygtk/gtk/__init__.py
# Copyright (C) 1998-2003  James Henstridge

class _DeprecatedConstant:
    def __init__(self, value, name, suggestion):
        self._v = value
        self._name = name
        self._suggestion = suggestion

    def _deprecated(self, value):
        import warnings
        message = '%s is deprecated, use %s instead' % (self._name,
                                                        self._suggestion)
        warnings.warn(message, DeprecationWarning, 3)
        return value

    __nonzero__ = lambda self: self._deprecated(self._v == True)
    __int__     = lambda self: self._deprecated(int(self._v))
    __str__     = lambda self: self._deprecated(str(self._v))
    __repr__    = lambda self: self._deprecated(repr(self._v))
    __cmp__     = lambda self, other: self._deprecated(cmp(self._v, other))

TRUE = _DeprecatedConstant(True, 'gimpenums.TRUE', 'True')
FALSE = _DeprecatedConstant(False, 'gimpenums.FALSE', 'False')

del _DeprecatedConstant

So I think this means you should use True instead: )
Reply


Messages In This Thread
RE: What's up with the all caps TRUE and FALSE ? - by Ofnuts - 10-16-2021, 12:55 AM

Forum Jump: