[Python] Documenting a variable in Python inside a Class in VSCode? [duplicate]

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    There is an answer (Docstring for variable) already but doesn't work with the hover on a variable to document in VSCode.

    How to add a comment or docstring for documenting a variable in python? such that when I hover on it with a mouse, in VSCode, it shows me the documentation in the hover box.

    For example:

    class MyClass:
    def __init__(self, conn, cursor):
    self.conn = conn
    """this is a Real Dict Cursor {} not a Normal List Cursor []"""
    self.cursor = cursor(cursor_factory=psycopg2.extras.RealDictCursor)


    I have tried using comments and doctrings but hovering on the variable in VSCode doesn't show any of that.

    Continue reading...

Compartilhe esta Página