Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2.7': 0.04; 'python': 0.08; '%s"': 0.09; '>>>>': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; 'truncate': 0.09; '~ethan~': 0.09; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '3.2.': 0.16; '[gcc': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'received:gateway13.websitewelcome.com': 0.16; 'roy': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'header:In-Reply-To:1': 0.22; 'print': 0.29; 'does': 0.32; 'to:addr:python-list': 0.33; 'header :User-Agent:1': 0.34; 'anything': 0.36; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'received:websitewelcome.com': 0.64; 'received:184': 0.67 Date: Tue, 23 Aug 2011 16:44:29 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: python-list@python.org Subject: Re: truncating strings References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:4252 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314142071 news.xs4all.nl 23847 [2001:888:2000:d::a6]:33050 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12123 Seebs wrote: > On 2011-08-23, Ethan Furman wrote: >> Seebs wrote: >>> On 2011-08-23, Roy Smith 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~