There is not much point in using the dictionary literal as the right argument % . It takes up a lot of space without improving the readability of your code.
confirmation_message = _('ORDER_CREATED: %s - %s - %s - %s') % ( order.lorem, order.ipsum, order.dolor, order.sit )
The operator.attrgetter function is useful here:
import operator attrs = operator.attrgetter('lorem', 'ipsum', 'dolor', 'sit') confirmation_message = _('ORDER_CREATED: %s - %s - %s - %s') % attrs(order)
If you can, switch to the format method:
msg_template = 'ORDER_CREATED: {0.lorem} - {0.ipsum} - {0.dolor} - {0.sit}' confirmation_message = _(msg_template).format(order)
source share