Coerce that can pay attention to type of operation

Huaiyu Zhu hzhu at yahoo.com
Mon Oct 2 04:36:41 EDT 2000


On Mon, 02 Oct 2000 00:21:03 GMT, jepler epler <jepler.lnk at lnk.ispi.net> wrote:

>(*) I have also often wished that __str__ could take the width specifiers
>given in the formatting operator, so that "%5.3s"%a would call a.__str__(5,3)
>if a.__str__ is able to take arguments.  Thus, objects would have the
>opportunity to smartly format themselves in the available space.

Or more generally,

"%80.2.3.5s" % a  == str(a, 80, 2, 3, 5)

which could be used to format more complicated objects in a very clean and
efficient way.

Huaiyu




More information about the Python-list mailing list