% operator -- did Python or C++/boost come first?

sismex01 at hebmex.com sismex01 at hebmex.com
Mon Jul 14 16:38:23 EDT 2003


> From: roy at panix.com [mailto:roy at panix.com] 
> Sent: Lunes, 14 de Julio de 2003 03:28 p.m.
> 
> Up until recently, Python was the only language I'd ever seen that
> used the % operator for string replacement.  Today, I was perusing the
> C++ Boost libraries, and discoverd that boost::format uses a very
> similar syntax.  The following lines print the same thing in Python
> and C++, respectively.
> 
> print "int->%i, string->%s" % (42, "wugga, wugga")
> cout << boost::format ("int->%i, string->%s\n") % 42 % "wugga, wugga";
> 
> The question is, which came first?  Did boost adapt the Python syntax,
> or the other way around, or did they both evolve in parallel?  I'm not
> talking about the use of % in the C/printf style format specifier, but
> the use of % as an operator to connect the format specifier with the
> data to be formatted.
>

I don't think anybody copied anybody's idea, rather, it's quite
logical to think up "%" as a string-formatting operator, because
of it's ties with it's use in printf() style format strings.

-gustavo


Advertencia:La informacion contenida en este mensaje es confidencial y
restringida, por lo tanto esta destinada unicamente para el uso de la
persona arriba indicada, se le notifica que esta prohibida la difusion de
este mensaje. Si ha recibido este mensaje por error, o si hay problemas en
la transmision, favor de comunicarse con el remitente. Gracias.





More information about the Python-list mailing list