With 10.8.beta6 
<https://github.com/sagemath/sage/commit/4e2319bc162a9f48b209cea89efe49e8c7e744e7>,
 
several methods computing the number of things that do not follow the 
naming scheme `n_xxx` or `number_of_xxx` became aliases.  For example, we 
now have `Graph(3).n_vertices()`, and the method name `num_verts` is an 
alias for `n_vertices`.

IMPORTANT INTERLUDE: `num_verts` is not deprecated.

This move has some advantages, but also one disadvantage: it clutters 
tab-completion.

I experimented a little, and found a way to hide aliases from 
tab-completion, as follows:

class AlternatingSignMatrix(...):
    ...
    def __init__(self, parent, asm):
        ...
        self._matrix = asm
        self.__setattr__('number_negative_ones', 
self.number_of_negative_ones)
        Element.__init__(self, parent)
  
    def __dir__(self):
        return [f for f in super().__dir__() if f != "number_negative_ones"]

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

Martin

PS: I found one "ordinary" class messing with `__dir__`, namely 
`Polyhedron_ZZ`, but I don't see any reason why the above approach would be 
problematic.

-- 
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/02e33df5-edc1-4a90-8f83-af4624426757n%40googlegroups.com.

Reply via email to