Why do we use .format, vs '%.2f' % order.get_cost() in django paypal -


just want ask quick question clarify things me, learning django paypal following tut , came accross following when creating payment processing view when creating paypal_dict:

'amount':'%.2f' % order.get_total_cost().quantize(                                             decimal('.01')), 'item_name':'order {}'.format(order.id),  

my question is, why can't following:

'amount':'{}.2f'.format(order.get_total_cost().quantize(                                             decimal('.01')) 

or

'item_name':'order %' % str(order.id) 

thanks!

you can use either % or format depending on prefer.

in single codebase, recommend picking 1 style , sticking consistency.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -