[COFF] fmt Strings. (Was: A few comments on porting the Bourne shell)

Ralph Corderoy ralph at inputplus.co.uk
Sat Dec 31 21:57:19 AEST 2022


Hi Larry,

> I hate Python because there is no printf in the base language.

There's print() with the format-string part being promoted into the
language as the ‘%’ operator when the left operand is a string.
It returns a string.

    >>> '%10d' % (6*7)
    '        42'
    >>> '%s %s!\n' % ('hello', 'world')
    'hello world!\n'
    >>> '%10d' % 6*7
    '         6         6         6         6         6         6         6'
    >>> print('foo')
    foo
    >>> print('%.3s' % 'barxyzzy')
    bar
    >>> 

So similar to AWK or Perl's sprintf() and Go's fmt.Sprintf() in that it
returns a dynamically-allocated string.

-- 
Cheers, Ralph.


More information about the COFF mailing list