On 26Apr2017 22:51, Tim Peters <tim.pet...@gmail.com> wrote:
[boB Stepp <robertvst...@gmail.com>, on %i/%d and %f/%F]
Hmm.  I'm surprised this slight distinction was worth keeping two
format codes that otherwise do the same thing.  Is there an actual
need for these due to Python being implemented behind the scenes in C?

The implementation is irrelevant to this.  What is relevant:  Python
took its format-string semantics from C.  Because of that alone, any
deviation from what the C docs say has to have very strong
justification.  "It's just like C" saves us from needing to write our
own mountains of tutorials and reference material.   The C world -
which has way more people and money supporting it - did that for us.

Another reason for this kind of thing is that if the printf codes are used faithfully WRT the C printf codes it makes reproducing specific outputs a bit easier.

It is a bit of a niche, but sometimes one wants to write something in Python whose output perfectly mimics that of another tool, usually because that output is in turn parsed by some utility one wants to use. If the target output was generated with printf, and if even better its source is available, one can just reuse the formats rather than having to laboriously reproduce special stuff.

Definitely a niche, and probably not the core motivation here. But handy.

Cheers,
Cameron Simpson <c...@zip.com.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to