X Tutup
Skip to content

Python expansion: Private attributes, hide or sort after public? #62

@ikanobori

Description

@ikanobori

Thanks for the excellent bpython.

I would like to propose some different behaviour for displaying private/internal attributes (i.e., those prefixed with _). This is the current behaviour:

>>> a=""
>>> a.
┌──────────────────────────────────────────────────────────────┐
│__add__                     __class__                         │
│__contains__                __delattr__                       │
│__doc__                     __eq__                            │
│__format__                  __ge__                            │
│__getattribute__            __getitem__                       │
│__getnewargs__              __getslice__                      │
│__gt__                      __hash__                          │
│__init__                    __le__                            │
│__len__                     __lt__                            │
│__mod__                     __mul__                           │
│__ne__                      __new__                           │
│__reduce__                  __reduce_ex__                     │
│__repr__                    __rmod__                          │
│__rmul__                    __setattr__                       │
│__sizeof__                  __str__                           │
│__subclasshook__            _formatter_field_name_split       │
│_formatter_parser           capitalize                        │
│center                      count                             │
│decode                      encode                            │
│endswith                    ...                               │
└──────────────────────────────────────────────────────────────┘

I propose two changes:

Change the sorting behaviour, so that attributes prefixed with _ appear after all other attributes. This means public members are seen first. It shouldn't change the sorting behaviour of attribute names that contain an _ in a different position.

Add an option to disable the display of these attributes. The user can still get those completions, but they have to type a._ to force those completions to become visible.


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup