Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.109 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.79; '*S*': 0.00; 'width': 0.09; 'kurt': 0.12; 'aligned.': 0.16; 'pythonic': 0.16; 'thursday,': 0.16; 'do,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'file,': 0.19; 'command': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'unicode': 0.24; 'header:In-Reply-To:1': 0.27; "i'd": 0.34; 'prepare': 0.35; 'there': 0.35; 'false': 0.36; 'should': 0.36; 'list': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'life,': 0.60; 'august': 0.61; 'real': 0.63; 'life': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:gmail.com': 0.80; '2013': 0.98 X-Virus-Scanned: amavisd-new at aerodynamics.ch Date: Thu, 08 Aug 2013 17:24:49 +0200 From: Kurt Mueller Organization: Rothenburg User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: python-list@python.org Subject: Re: right adjusted strings containing umlauts References: <9781df99-f9c8-4217-aa67-7a714b7f2ebe@googlegroups.com> In-Reply-To: <9781df99-f9c8-4217-aa67-7a714b7f2ebe@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: kurt.alfred.mueller@gmail.com 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375975522 news.xs4all.nl 15966 [2001:888:2000:d::a6]:54035 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52203 Am 08.08.2013 16:43, schrieb jfharden@gmail.com: > On Thursday, 8 August 2013 15:23:46 UTC+1, Kurt Mueller wrote: >> I'd like to print strings right adjusted. >> print( '>{0:>3}<'.format( '=E4' ) ) >=20 > Make both strings unicode > print( u'>{0:>3}<'.format( u'=E4' ) ) > Why not use rjust for it though? > u'=E4'.rjust(3) In real life there is a list of strings in output_list from a command lik= e: output_list =3D shlex.split( input_string, bool_cmnt, bool_posi, ) input_string is from a file, bool_* are either True or False repr( output_list ) ['\xc3\xb6', '\xc3\xbc', 'i', 's', 'f'] which should be printed right aligned. using: print( u'{0:>3} {1:>3} {2:>3} {3:>3} {4:>3}'.format( *output_list ) ) ( In real life, the alignement and the width is variable ) How do I prepare output_list the pythonic way to be unicode strings? What do I do, when input_strings/output_list has other codings like iso-8= 859-1? TIA --=20 Kurt Mueller