如何打破以下的python行

时间:2010-02-15 14:50:06

标签: python pep8

我遇到了几行与此类似的代码,但我不确定如何打破它:

blueprint = Blueprint(self.blueprint_map[str(self.ui.blueprint_combo.currentText())], runs=self.ui.runs_spin.text(), me=self.ui.me_spin.text(), pe=self.ui.pe_skill_combo.currentIndex())

提前致谢

5 个答案:

答案 0 :(得分:14)

blueprint = Blueprint(
    self.blueprint_map[str(self.ui.blueprint_combo.currentText())],
    runs=self.ui.runs_spin.text(), 
    me=self.ui.me_spin.text(),
    pe=self.ui.pe_skill_combo.currentIndex(),
)

答案 1 :(得分:5)

这个怎么样

blueprint_item = self.blueprint_map[str(self.ui.blueprint_combo.currentText())]
blueprint = Blueprint(blueprint_item,
                      runs=self.ui.runs_spin.text(),
                      me=self.ui.me_spin.text(),
                      pe=self.ui.pe_skill_combo.currentIndex())

答案 2 :(得分:4)

我这样做:

blueprint = Blueprint(
              self.blueprint_map[str(self.ui.blueprint_combo.currentText())],
              runs=self.ui.runs_spin.text(),
              me=self.ui.me_spin.text(),
              pe=self.ui.pe_skill_combo.currentIndex())

答案 3 :(得分:0)

括号内的任何地方都应该有效,例如:

blueprint = Blueprint(self.blueprint_map[str(self.ui.blueprint_combo.currentText())],
        runs=self.ui.runs_spin.text(), me=self.ui.me_spin.text(),
        pe=self.ui.pe_skill_combo.currentIndex())

答案 4 :(得分:0)

blueprint = Blueprint(self.blueprint_map[str(self.ui.blueprint_combo.currentText())], 
                      runs=self.ui.runs_spin.text(), me=self.ui.me_spin.text(),
                      pe=self.ui.pe_skill_combo.currentIndex())