[Python] Is "*_" an acceptable way to ignore arguments in Python?

Discussão em 'Python' iniciado por Stack, Junho 14, 2025.

  1. Stack

    Stack Membro Participativo

    If I have a function/method that is an implementation of a callback for some framework, and do not care for any further arguments, it seems to be syntactically correct, and to not have pylint/IDE complaints to use *_ to express no interest in any further arguments. The point I think is to express intent to both the tools, and other developers that these arguments are not currently relevant.

    To clarify what I mean:

    def my_callbacK_handler(a, b, *_):
    ...


    I've not seen this idiom used in the wild - is it common, are there examples and are there known problems with this?

    For those not familiar: _ expresses the intent that I am not interested in that symbol - it is the Python "dummy" that is recognized by IDE's and linters.

    Continue reading...

Compartilhe esta Página