truncating strings

Seebs usenet-nospam at seebs.net
Tue Aug 23 16:52:55 EDT 2011


On 2011-08-23, Roy Smith <roy at panix.com> wrote:
> I want to log a string but only the first bunch of it, and add "..."
> to the end if it got truncated.  This certainly works:

>           logger.error("FAILED: '%s{50}', '%s', %s, %s" % (message,
> route, params, e.code))

> does anything like this exist?

%.50s

-s
-- 
Copyright 2011, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.



More information about the Python-list mailing list