python / python/cpython

Add more useful help for special name in `help()`

Offen
#137,574 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

interpreter-core type-feature
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Feature or enhancement

Proposal:

Now, use help("__name__") and some other special variables' names will still get the help from their class. I think that we can add the useful help on them. For example:

>>>help("__name__")
1. module.__name__ : if the module is run as the main module, the value is ‘_main_‘, or the name is the filename of the module. For example:if __name__ == "__main__": ...can control which code don’t run when the module is imported.

2. cls.__name__: the name of the class. It must be str.

For other special variables (such as __file__), we can alse print the similar detailed help. And I think that the sentences need to be friendly.

Also welcome to give the ideals on new ideas

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-137966

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, help("name") auszuführen und die aktuelle Ausgabe mit den vorgeschlagenen Beispielen für name und file zu vergleichen. Als erledigt gilt die Aufgabe, wenn help() freundliche, nützliche Erklärungen für die ausgewählten speziellen Variablen liefert; prüfe den verknüpften PR gh-137966, bevor du beginnst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
documentation
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.