[Python] Are there conventions as to what to name parameters in Python that could be "format"...

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

  1. Stack

    Stack Membro Participativo

    I am currently developing a toolbox in Python, and some of my functions contain a parameter that allow to decide in which format/type to return a value.

    e.g. (this is of course a dumb example as we could very well convert the types afterwards, but my real use-cases are more complex):

    def foo(a, b, format="str"):
    if format == "str":
    return str(a + b)
    elif format == "float":
    return float(a + b)
    else:
    raise Exception("Invalid parameter format").


    Editors such as PyCharm underline "format" or "type" as they shadow built-in names.

    Are there any conventions as to how to replace these?

    Continue reading...

Compartilhe esta Página