在Python3.2中我可以这样做:
foo = Bar()
foo.setSomething(something1).setStatus('horizontal').setAttributes(attributes)
最终链条变得相当长。我渴望垂直链接。
foo = Bar()
foo.setSomething(something1)
.setStatus('vertical')
.setAttributes(attributes)
有什么办法可以做到这一点吗?
最佳答案
只需将您的表达式括在括号中即可:
foo = Bar()
(foo.setSomething(something1)
.setStatus('vertical')
.setAttributes(attributes))
关于Python3.2垂直链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13685670/