diff --git a/Lib/_pydecimal.py b/Lib/_pydecimal.py index 0fa152c2a6f..edabf72aa7a 100644 --- a/Lib/_pydecimal.py +++ b/Lib/_pydecimal.py @@ -1674,13 +1674,13 @@ class Decimal(object): __trunc__ = __int__ + @property def real(self): return self - real = property(real) + @property def imag(self): return Decimal(0) - imag = property(imag) def conjugate(self): return self diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py index c425fe68274..2a6ef2ef524 100644 --- a/Lib/lib2to3/pytree.py +++ b/Lib/lib2to3/pytree.py @@ -271,7 +271,8 @@ class Node(Base): for child in self.children: yield from child.pre_order() - def _prefix_getter(self): + @property + def prefix(self): """ The whitespace and comments preceding this node in the input. """ @@ -279,12 +280,11 @@ class Node(Base): return "" return self.children[0].prefix - def _prefix_setter(self, prefix): + @prefix.setter + def prefix(self, prefix): if self.children: self.children[0].prefix = prefix - prefix = property(_prefix_getter, _prefix_setter) - def set_child(self, i, child): """ Equivalent to 'node.children[i] = child'. This method also sets the @@ -380,18 +380,18 @@ class Leaf(Base): """Return a pre-order iterator for the tree.""" yield self - def _prefix_getter(self): + @property + def prefix(self): """ The whitespace and comments preceding this token in the input. """ return self._prefix - def _prefix_setter(self, prefix): + @prefix.setter + def prefix(self, prefix): self.changed() self._prefix = prefix - prefix = property(_prefix_getter, _prefix_setter) - def convert(gr, raw_node): """ Convert raw node information to a Node or Leaf instance. diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index d49e8f0d32b..ba9b17cee1b 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -465,8 +465,13 @@ class Listener(object): self._listener = None listener.close() - address = property(lambda self: self._listener._address) - last_accepted = property(lambda self: self._listener._last_accepted) + @property + def address(self): + return self._listener._address + + @property + def last_accepted(self): + return self._listener._last_accepted def __enter__(self): return self diff --git a/Lib/multiprocessing/dummy/__init__.py b/Lib/multiprocessing/dummy/__init__.py index 1abea64419b..cbb7f4909cb 100644 --- a/Lib/multiprocessing/dummy/__init__.py +++ b/Lib/multiprocessing/dummy/__init__.py @@ -98,11 +98,15 @@ class Value(object): def __init__(self, typecode, value, lock=True): self._typecode = typecode self._value = value - def _get(self): + + @property + def value(self): return self._value - def _set(self, value): + + @value.setter + def value(self, value): self._value = value - value = property(_get, _set) + def __repr__(self): return '<%s(%r, %r)>'%(type(self).__name__,self._typecode,self._value) diff --git a/Lib/multiprocessing/dummy/connection.py b/Lib/multiprocessing/dummy/connection.py index 19843751c0c..f0ce320fcf5 100644 --- a/Lib/multiprocessing/dummy/connection.py +++ b/Lib/multiprocessing/dummy/connection.py @@ -26,7 +26,9 @@ class Listener(object): def close(self): self._backlog_queue = None - address = property(lambda self: self._backlog_queue) + @property + def address(self): + return self._backlog_queue def __enter__(self): return self diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py index b9ce84b2d85..43dd02a5a39 100644 --- a/Lib/multiprocessing/managers.py +++ b/Lib/multiprocessing/managers.py @@ -628,7 +628,9 @@ class BaseManager(object): except KeyError: pass - address = property(lambda self: self._address) + @property + def address(self): + return self._address @classmethod def register(cls, typeid, callable=None, proxytype=None, exposed=None, diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 49555405c56..376c4459fe6 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1868,8 +1868,13 @@ class Helper: self._input = input self._output = output - input = property(lambda self: self._input or sys.stdin) - output = property(lambda self: self._output or sys.stdout) + @property + def input(self): + return self._input or sys.stdin + + @property + def output(self): + return self._output or sys.stdout def __repr__(self): if inspect.stack()[1][3] == '?': diff --git a/Lib/tarfile.py b/Lib/tarfile.py index c3777ff2dde..2d702dd2ec6 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -761,17 +761,21 @@ class TarInfo(object): # In pax headers the "name" and "linkname" field are called # "path" and "linkpath". - def _getpath(self): + @property + def path(self): return self.name - def _setpath(self, name): - self.name = name - path = property(_getpath, _setpath) - def _getlinkpath(self): + @path.setter + def path(self, name): + self.name = name + + @property + def linkpath(self): return self.linkname - def _setlinkpath(self, linkname): + + @linkpath.setter + def linkpath(self, linkname): self.linkname = linkname - linkpath = property(_getlinkpath, _setlinkpath) def __repr__(self): return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self)) diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py index 2cff1c526ed..9c216d3eb7b 100644 --- a/Lib/test/test_pyclbr.py +++ b/Lib/test/test_pyclbr.py @@ -160,7 +160,7 @@ class PyclbrTest(TestCase): cm('aifc', ignore=('openfp', '_aifc_params')) # set with = in module cm('sre_parse', ignore=('dump', 'groups', 'pos')) # from sre_constants import *; property cm('pdb') - cm('pydoc') + cm('pydoc', ignore=('input', 'output',)) # properties # Tests for modules inside packages cm('email.parser') diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py index c474e60713f..cbaad76e008 100644 --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -1577,20 +1577,17 @@ class LabeledScale(Frame): self.label['text'] = newval self.after_idle(adjust_label) - - def _get_value(self): + @property + def value(self): """Return current scale value.""" return self._variable.get() - - def _set_value(self, val): + @value.setter + def value(self, val): """Set new scale value.""" self._variable.set(val) - value = property(_get_value, _set_value) - - class OptionMenu(Menubutton): """Themed OptionMenu, based after tkinter's OptionMenu, which allows the user to select a value from a menu."""