A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/066264.html below:

[Python-Dev] PyString_FromFormat

[Python-Dev] PyString_FromFormat"Martin v. Löwis" martin at v.loewis.de
Tue Jun 20 00:58:05 CEST 2006
Kristján V. Jónsson wrote:
> One thing I have often lamented having in PyString_FromFormat (and
> cousins, like PyErr_Format) is to be able to integrate PyObject
> pointers.  Adding something like %S and %R (for str() and repr()
> respectively) seems very useful to me.  Is there any reason why this
> isn´t there?

Not sure what the specific use case is, but I think I would use
PyString_Format instead, and use everything you can use in a %
operator. If you want to avoid explicit argument tuple building,
you can also write

  static PyObject *fmt = NULL;
  if (!fmt) fmt = PyString_FromString("Foo %s bar %s foobar %d");
  res = PyMethod_Call(fmt, "__mod__", "(OOi)", o1, o2, 42);

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4