3 ms·
In the example he gives, wouldn't it be more simple (if not idiomatic) to write print(index, element) instead of print ('{} {}'.format(index, element
by Orangeair 13y ago
In the example he gives, wouldn't it be more simple (if not idiomatic) to write
print(index, element)
instead of
print ('{} {}'.format(index, element)) ?
Why use string formatting for something so simple, especially when Python inserts spaces in between multiple items automatically?
- shin_lao 13y agoI think it's because you're likely to change formatting as your code evolve.
- avelis 13y agoI agree on both points. Therefore, when the time comes, change it. No need to over design if unnecessary. The reason I agree to using .format is because it is more expressive in describing the output vs inference in using print.
- d0mine 13y agoYou could use .format() to support both Python 2 and 3 from the same source