I have a long function, as seen below:
hash_correct = hashlib.md5(salt + password)).digest().encode("base64")
I’d like to split it up into two lines but am not sure of the correct way to do this in Python?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The coding guidelines limiting length of lines is there, in part, to make the code more readable. In your case of chained method calls, the meaning is not clear. You should pick some temporary variable names for the intermediate values so that a reader of the code can understand the chain easily.
One example might be:
This leads the reader down a garden path to understanding. Very little is lost in performance, and the additional code is all added for purpose.