Possible to call single-parameter Python function without using parentheses?

前端 未结 4 1402
南方客
南方客 2021-01-05 15:40

The Python documentation specifies that is is legal to omit the parentheses if a function only takes a single parameter, but

    myfunction \"Hello!\"
         


        
4条回答
  •  日久生厌
    2021-01-05 16:07

    As I understand the rule is only about the generator expressions... so for example: sum(x2 for x in range(10)), but you would still have to write: reduce(operator.add, (x2 for x in range(10))).

    This doesn't apply for generic functions though.

提交回复
热议问题