Juliusz Gonera Juliusz Gonera - 1 year ago 101
Python Question

How to break a line of chained methods in Python?

I have a line of the following code (don't blame for naming conventions, they are not mine):

subkeyword = Session.query(
Subkeyword.subkeyword_id, Subkeyword.subkeyword_word

I don't like how it looks like (not too readable) but I don't have any better idea to limit lines to 79 characters in this situation. Is there a better way of breaking it (preferably without backslashes)?

sth sth
Answer Source

You could use additional parenthesis:

subkeyword = (
    Session.query(Subkeyword.subkeyword_id, Subkeyword.subkeyword_word)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download