1👍
✅
You can work with itertools.zip_longest(…)
[Python-doc] to put None
values when one of the methods end, so:
from itertools import zip_longest
class FilterText:
def total_cost_fruit(self):
return [3588.20, 5018.75, 3488.16, 444]
def total_cost_fruit2(self):
return [3588.20, 5018.75, 3488.99]
def total_cost_fruit3(self):
return [3588.20, 5018.75, 44.99]
def show_extracted_data_from_file(self):
regexes = [
self.total_cost_fruit(),
self.total_cost_fruit2(),
self.total_cost_fruit3(),
]
return zip_longest(*regexes)
You can also render this more conveniently with:
<div class="wishlist"> <table> <tr> <th>Method 1</th> <th>Method 2</th> <th>Method 3</th> </tr> {% for value0, value1, value2 in content_pdf %} <tr> <td>{{ value0 }}</td> <td>{{ value1 }}</td> <td>{{ value2 }}</td> </tr> {% endfor %} </table> </div>
Source:stackexchange.com