truncating strings
Ethan Furman
ethan at stoneleaf.us
Tue Aug 23 19:44:29 EDT 2011
Seebs wrote:
> On 2011-08-23, Ethan Furman <ethan at stoneleaf.us> wrote:
>> Seebs wrote:
>>> On 2011-08-23, Roy Smith <roy at panix.com> wrote:
>>>> logger.error("FAILED: '%s{50}', '%s', %s, %s" % (message,
>>>> route, params, e.code))
>
>>>> does anything like this exist?
>
>>> %.50s
>
>> That's not working in 2.7 or 3.2.
>
> Huh.
>
> Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> print "%.5s" % ("hello there, truncate me!")
> hello
Ah -- that's only part of it -- the OP wants '...' to print as well. :)
~Ethan~
More information about the Python-list
mailing list