I want to use autocomplete in ipython and jupyter for the following code with read-only class attributes (using @property
):
class A(object):
def __init__(self):
self.__value = 1
@property
def value(self):
return self.__value
class B(object):
def __init__(self):
self.a = A()
class C(object):
def __init__(self):
self.__a = A()
@property
def a(self):
return self.__a
b = B()
c = C()
Both
>>> b.a.value
and
>>> c.a.value
work well. But autocomplete for ipython and jupyter notebook works only for
>>> b.a.value
and
>>> c.a.
without tab-autocomplete.
How to rewrite the code to achieve c.a.<tab> -> c.a.value
autocomplete in ipython and jupyter notebook?