|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这是一封信件:
- Python already allows positional arguments after keyword
- arguments:
- py> sorted(reverse=True, *([1, 4, 2, 3],))
- [4, 3, 2, 1]
-
- Haha, that's very clever. I had to think for a bit about why that's allowed. So let me specify: we don't allow non-variadic positional arguments after keyword arguments, and I don't think we ever will or should.
-
- I have an actual, concrete possible enhancement in mind: relaxing the
- restriction on parameter order.
- What? Do you think that the current restriction is bad, and we should just drop it? Why?
复制代码
啥意思呢?
其实,光看这一部分:
- py> sorted(reverse=True, *([1, 4, 2, 3],)) # 这里加个逗号,是为了保证它是一个可迭代对象,而不是4个数
- [4, 3, 2, 1]
复制代码
!!!Python居然允许关键字参数在位置参数前面了!
我自己试了试,也是可以的!
各位觉得这是一件好事还是坏事呢?
|
|