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


Groups > comp.lang.python > #12123

Re: truncating strings

Date 2011-08-23 16:44 -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> <mailman.368.1314135952.27778.python-list@python.org> <slrnj588mv.96g.usenet-nospam@guild.seebs.net>
Newsgroups comp.lang.python
Message-ID <mailman.371.1314142071.27778.python-list@python.org> (permalink)

Show all headers | View raw


Seebs wrote:
> On 2011-08-23, Ethan Furman <ethan@stoneleaf.us> wrote:
>> Seebs wrote:
>>> On 2011-08-23, Roy Smith <roy@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~

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