# Add a flag "hide magic names" in dir

**URL:** <https://discuss.python.org/t/add-a-flag-hide-magic-names-in-dir/7276>\
**Category:** Ideas\
**Created:** [February 19, 2021, 9:26am UTC](https://discuss.python.org/t/add-a-flag-hide-magic-names-in-dir/7276 "2021-02-19T09:26:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nuno](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nuno/32/3756_2.png) [@nuno](https://discuss.python.org/u/nuno)\
**Post date:** [March 21, 2021, 4:46am UTC](https://discuss.python.org/t/add-a-flag-hide-magic-names-in-dir/7276/2 "2021-03-21T04:46:23Z")

</div>

`dir` is a convenience function that most of the time delegates to the object’s ` __dir__ ` implementation ([only performs an inspection if cannot find it](https://github.com/python/cpython/blob/3.9/Objects/object.c#L1470)).

There are several ` __dir__ ` implementations in Python’s code (modules, classes, other objects, …) and each one displays the most relevant information for an interactive context with different criteria, as do so many other ` __dir__ ` implementations in the vast Python ecosystem. Presuming the normality of an attribute on the basis of underscores sounds kinda dunderphobic to me 😅 Sorry, just kidding. What I mean is that since dunders are only a convention (except in the case of name mangling), often it would be difficult to know what kind of information is being hidden.

IMO this is a case that fits perfectly with the purpose of `PYTHONSTARTUP`. I usually have a very small wrapper over `dir()` in mine to identify methods at a glance and I found it very convenient. Adapted to your idea, would be something like this:

```auto
def ddir(obj):
    return [a + '()' if callable(getattr(obj, a)) else a
            for a in dir(obj) if not (a[:2] == '__' == a[-2:])]

```

---

_[View the full topic](https://discuss.python.org/t/add-a-flag-hide-magic-names-in-dir/7276)._
