You can. You must implement a __dir__()
method for your class, as discussed here.
This is an example of it working:
class bar(object):
def __init__(self,):
self.a = 4
self._morelements=['b']
def __dir__(self):
return sorted(set(dir(type(self)) + list(self.__dict__) + self._morelements))
foo=bar()
Now if you write foo.
and press TAB in Ipython you will have as available members both a
and b
, although b
does not exist.
The code for __dir__()
and a discussion of the limitations of this approach is here. In your case, you want to add description
to the list self._morelements
inside the function add_dimension()
.
EDIT:
And of course you also need to initialize self._morelements=[]
in the __init__()
, and add the __dir__()
function of the example above to your class Part