Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12118

Re: truncating strings

Date 2011-08-23 15:02 -0700
From Ethan Furman <ethan@stoneleaf.us>
Subject Re: truncating strings
References <a24faeb6-ebe4-41bf-8c20-9cd46547a3bd@b14g2000vbg.googlegroups.com> <slrnj584bv.4ta.usenet-nospam@guild.seebs.net>
Newsgroups comp.lang.python
Message-ID <mailman.368.1314135952.27778.python-list@python.org> (permalink)

Show all headers | View raw


Seebs wrote:
> On 2011-08-23, Roy Smith <roy@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

That's not working in 2.7 or 3.2.

~Ethan~

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

truncating strings Roy Smith <roy@panix.com> - 2011-08-23 09:29 -0700
  Re: truncating strings Chris Rebert <clp2@rebertia.com> - 2011-08-23 10:27 -0700
  Re: truncating strings Seebs <usenet-nospam@seebs.net> - 2011-08-23 20:52 +0000
    Re: truncating strings Ethan Furman <ethan@stoneleaf.us> - 2011-08-23 15:02 -0700
      Re: truncating strings Seebs <usenet-nospam@seebs.net> - 2011-08-23 22:00 +0000
        Re: truncating strings Ethan Furman <ethan@stoneleaf.us> - 2011-08-23 16:44 -0700
          Re: truncating strings Seebs <usenet-nospam@seebs.net> - 2011-08-24 04:21 +0000
        Re: truncating strings Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-24 11:24 +1000

csiph-web