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 ( but i can’t figure out how best to break it.

Can someone advise me please?


>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

Leave a Reply