Python: how to disable the keyword "property"?

I support an outdated python application that has a class written as such (still running in python 2.4):

class MyClass(object):

    def property(self, property_code, default):
        ...

Now I am adding a new code to it:

    def _check_ok(self):
        ...

    ok = property(lamdba self:self._check_ok())

Basically, I want to add the 'ok' property to this class .

However, this will not work. I came across this error message:

TypeError: property() takes at least 2 arguments (1 given)

The existing property class method has eclipsed the built-in property keyword.

Is there a way to use the 'property' as it was in my new code?

Refactoring an existing function is property()not a parameter.

EDIT: MyClass::property def, . ,

EDIT 2:

>>> class Jack(object):
...   def property(self, a, b, c):
...      return 2
...   p = __builtins__.property(lambda self: 1)
...
>>> a = Jack()
>>> a.p
1
>>> a.property(1, 2, 3)
2

. Got AttributeError: 'dict' < >

+3
2

Python 2:

import __builtin__
__builtin__.property

Python 3:

import builtins
builtins.property
+8

:

__builtins__.property(lamdba self:self._check_ok())
0

Source: https://habr.com/ru/post/1783984/


All Articles