Search code examples
pythonpep8

Python - Line too long, how can I break this?


I have this line of code:

self.order_total = self.lineitems.aggregate(Sum('lineitem_total'))['lineitem_total__sum'] or 0

It is too long for pep8 validation. I had a look at the docs (https://peps.python.org/pep-0008/#maximum-line-length) but i can't figure out how best to break it.

Can someone advise me please?

thanks


Solution

  • As I understand you mean Line Breaking. It is too easy

    self.order_total = self.lineitems.aggregate(
        Sum('lineitem_total'))['lineitem_total__sum'] or 0