Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split a long line in Python without \

I have a line of code in python that is way too long. I'm trying to format it, but my company doesn't allow the use of "\" to break lines. I tried it as such,

(subject, message, chatRoomMsg, chatRecipientMsg) = 
  set_mail_and_chat(user, user_dict[user])

How can I format this line to make it work, but also keep the line under 80 characters.

like image 915
frany Avatar asked Dec 04 '25 17:12

frany


2 Answers

Split it into two:

result = set_mail_and_chat(user, user_dict[user])
subject, message, chatRoomMsg, chatRecipientMsg = result
like image 75
Sait Avatar answered Dec 06 '25 08:12

Sait


You can leave the opening parenthesis in the first line, and continue in the second one:

subject, message, chatRoomMsg, chatRecipientMsg = (
    set_mail_and_chat(user, user_dict[user]))
like image 26
DzinX Avatar answered Dec 06 '25 07:12

DzinX