When I try your example in IPython `bad` is not visible to tab-completion 
for instances of `A` or instances of `B`. It is visible for `A` itself, but 
methods are normally called on instances, not classes so that's fine. When 
I try it with a regular Python prompt then it is as you said. So modifying 
__dir__ is sufficient for the IPython interface, and I'm happy to sacrifice 
alias handling for tab complete behaviour in a regular (not IPython) 
terminal if it means much simpler code. I'm not sure how many people use 
Sage in an interactive non-IPython terminal anyway.


That's interesting, so it possibly depends on the setup.  Here is a session 
on my computer:

sage: import IPython
sage: IPython.version_info
(8, 18, 1, '')
sage: ip = get_ipython()

sage: a = A()
sage: type(a)
<class '__main__.A'>
sage: ip.complete("a.b")
('a.b', ['a.bad'])
sage: b = B()
sage: type(b)
<class '__main__.B'>
sage: ip.complete("b.b")
('', [])
sage: b.bad()
42

(Ubuntu 24.04.3 LTS, SageMath 10.8.beta6, Python 3.12.3)

Martin

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/sage-devel/7501e2f9-524c-4fd0-a353-7b79daff66f1n%40googlegroups.com.

Reply via email to