On Tuesday, 7 October 2025 at 02:05:44 UTC-7 [email protected] wrote:

Is there any downside to this idea?  Of course, I would turn it into 
something easier to use, like a decorator.

I haven't thought through all the ramifications of this, but as a general 
principle, being "smart" by putting exceptions in your code for particular 
behaviour tends to come back to haunt you later. The Zen of Python even 
addresses this:

Special cases aren't special enough to break the rules. 

My main problem is that __dir__ isn't solely for displaying tab completion 
results. It's an introspection tool. So I don't think __dir__ is an 
appropriate place to sanitize your tab completion lists. Tab completion is 
an interface job -- in this case IPython. If you think the tab completion 
results need sanitizing after obtaining them through introspection from 
python, then it needs to be happening there.

If you want to group aliases together: you can probably systematically 
determine if two attributes are aliases by looking at the ID they point to. 
If these end up being bound methods, you may have to dig into it a little 
bit (e.g., look at the __func__ attribute of the method instead). A fancy 
tab completion could group aliases together and perhaps even have a way of 
displaying a "preferred" one.

Once you have a protocol for tab completion sanitation, the question would 
be where you store the info on which attributes should be displayed 
(perhaps a ranking for inclusion in tab completion lists of various levels 
of completeness?) Should this info be distributed or should it be stored 
centrally? Should it be user configurable?

For the most part I think these questions end up being interface questions, 
not questions particular to sagemath (although the needs of sagemath might 
be a bit different than for other python projects), so perhaps the right 
level to engage with them is to contribute tools for it to IPython/jupyter. 
The feedback and positive or negative reception there might also be 
informative. There are other python-based projects with way more 
experience/focus on user interface than sagemath. Let's try to be 
compatible with that.

-- 
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/da39b2e2-ca29-4b53-87cd-dcd614e99b2fn%40googlegroups.com.

Reply via email to