开发者

How to break the following line of python

I have come upon a couple of lines of code similar to this one, but I'm unsure how I should break it:

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())

Thanks in advanc开发者_StackOverflow社区e


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(),
)


How about this

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())


I'd do it this way:

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())


Anywhere within the brackets should work, such as:

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())


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())
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜