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

前端 未结 4 1417
南方客
南方客 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:16

    Without parentheses those wouldn't be functions but statements or keywords (language-intrinsic).

    This StackOverflow thread (with some very nice answers) contains a lead as to how one can create their own in pure Python (through advanced hackery, and not a good idea in 99.99% of the cases).

提交回复
热议问题