Reputation: 22942
How does string formats '%' operator is implemented in CPython 2.7?
Can't find any reference in the Python documentation.
Well, I fact I found the topic: String conversion and formatting, for PyOS_snprintf
and PyOS_vsnprintf
. But not sure it match my question.
See also my question Optional keys in string formats using '%' operator?
Upvotes: 0
Views: 101
Reputation: 133869
The implementation is in the PyString_Format
that is called by the string_mod
function in Objects/stringobject.c
. The latter in turn is a slot method stored in PyString_Type->tp_as_number->nb_remainder
.
The functions PyOS_*snprintf
are not really related to the implementation of str.__mod__
.
Upvotes: 2