Search code examples
pythonpep8continuation

How to limit lenght of a complicated line in Python?


I'm formatting my code according to PEP8, but I have a little issue; this is it:

print ("DB Updated: " + datetime.datetime.fromtimestamp(int(stats_dict["db_update"])).strftime('%a %b %d %H:%M:%S %Y'))

How to break it into lines with 72-79 characters?


Solution

  • from datetime import datetime
    
    dt = datetime.fromtimestamp(int(stats_dict["db_update"]))
    print("DB Updated: " + dt.strftime('%a %b %d %H:%M:%S %Y'))