On Wednesday, August 28, 2013 12:23:12 PM UTC+2, Dave Angel wrote:
> On 28/8/2013 04:01, Kurt Mueller wrote:
> > Because I cannot switch to Python 3 for now my life is not so easy:-)
> > For some text manipulation tasks I need a template to split lines
> > from stdin into a list of strings the way
On 28/8/2013 04:01, Kurt Mueller wrote:
> Because I cannot switch to Python 3 for now my life is not so easy:-)
>
> For some text manipulation tasks I need a template to split lines
> from stdin into a list of strings the way shlex.split() does it.
> The encoding of the input can vary.
> For furt
Am 08.08.2013 18:37, schrieb Chris Angelico:
> On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller
> wrote:
>> Am 08.08.2013 17:44, schrieb Peter Otten:
>>> Kurt Mueller wrote:
What do I do, when input_strings/output_list has other codings like
iso-8859-1?
>>> You have to know the actual encodi
Am 08.08.2013 18:37, schrieb Chris Angelico:
> On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller
> wrote:
>> Am 08.08.2013 17:44, schrieb Peter Otten:
>>> Kurt Mueller wrote:
What do I do, when input_strings/output_list has other codings like
iso-8859-1?
>>> You have to know the actual encodi
On Thu, 08 Aug 2013 17:24:49 +0200, Kurt Mueller wrote:
> What do I do, when input_strings/output_list has other codings like
> iso-8859-1?
When reading from a text file, honour some sort of encoding cookie at the
top (or bottom) of the file, like Emacs and Vim use, or a BOM. If there
is no enc
Le jeudi 8 août 2013 18:27:06 UTC+2, Kurt Mueller a écrit :
> Now I have this small example:
>
> --
>
> #!/usr/bin/env python
>
> # vim: set fileencoding=utf-8 :
>
>
>
> from __future__ import print_function
>
> import sys, shlex
>
>
On 8/8/2013 11:24 AM, Kurt Mueller wrote:
print( u'{0:>3} {1:>3} {2:>3} {3:>3} {4:>3}'.format( *output_list ) )
Using autonumbering feature, same as
print( u'{:>3} {:>3} {:>3} {:>3} {:>3}'.format( *output_list ) )
print( (u' '.join([u'{:>3}']*5)).format(*output_list) )
print( (u' '.join([u'{:
Kurt Mueller wrote:
> Now I have this small example:
> --
> #!/usr/bin/env python
> # vim: set fileencoding=utf-8 :
>
> from __future__ import print_function
> import sys, shlex
>
> print( repr( sys.stdin.encoding ) )
>
> strg_form = u'{0:>3}
On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller
wrote:
> Am 08.08.2013 17:44, schrieb Peter Otten:
>> Kurt Mueller wrote:
>>> What do I do, when input_strings/output_list has other codings like
>>> iso-8859-1?
>>
>> You have to know the actual encoding. With that information it's easy:
> output_l
Kurt Mueller wrote:
> Am 08.08.2013 17:44, schrieb Peter Otten:
>> Kurt Mueller wrote:
>>> What do I do, when input_strings/output_list has other codings like
>>> iso-8859-1?
>>
>> You have to know the actual encoding. With that information it's easy:
> output_list
>> ['\xc3\xb6', '\xc3\xbc',
Now I have this small example:
--
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
from __future__ import print_function
import sys, shlex
print( repr( sys.stdin.encoding ) )
strg_form = u'{0:>3} {1:>3} {2:>3} {3:>3} {4:>3}'
for inpt_l
Am 08.08.2013 17:44, schrieb Peter Otten:
> Kurt Mueller wrote:
>> What do I do, when input_strings/output_list has other codings like
>> iso-8859-1?
>
> You have to know the actual encoding. With that information it's easy:
output_list
> ['\xc3\xb6', '\xc3\xbc', 'i', 's', 'f']
encoding
Kurt Mueller wrote:
> Am 08.08.2013 16:43, schrieb jfhar...@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( 'ä' ) )
>>
>> Make both strings unicode
>> print( u'>{0:>3}<'.format( u'ä' ) )
>> W
Kurt Mueller wrote:
> Am 08.08.2013 16:43, schrieb jfhar...@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( 'ä' ) )
>>
>> Make both strings unicode
>> print( u'>{0:>3}<'.format( u'ä' ) )
>> W
Am 08.08.2013 16:43, schrieb jfhar...@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( 'ä' ) )
>
> Make both strings unicode
> print( u'>{0:>3}<'.format( u'ä' ) )
> Why not use rjust for it though
On 08/08/2013 15:40, Neil Cerutti wrote:
On 2013-08-08, Kurt Mueller wrote:
I'd like to print strings right adjusted.
( Python 2.7.3, Linux 3.4.47-2.38-desktop )
from __future__ import print_function
print( '>{0:>3}<'.format( 'a' ) )
a<
But if the string contains an Umlaut:
print( '>{0:>3}
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( 'ä' ) )
>
Make both strings unicode
print( u'>{0:>3}<'.format( u'ä' ) )
Why not use rjust for it though?
u'ä'.rjust(3)
--
Jonathan
--
http://mail.python
On 2013-08-08, Kurt Mueller wrote:
> I'd like to print strings right adjusted.
> ( Python 2.7.3, Linux 3.4.47-2.38-desktop )
>
> from __future__ import print_function
> print( '>{0:>3}<'.format( 'a' ) )
>> a<
>
> But if the string contains an Umlaut:
> print( '>{0:>3}<'.format( '??' ) )
>> ??<
>
I'd like to print strings right adjusted.
( Python 2.7.3, Linux 3.4.47-2.38-desktop )
from __future__ import print_function
print( '>{0:>3}<'.format( 'a' ) )
> a<
But if the string contains an Umlaut:
print( '>{0:>3}<'.format( 'ä' ) )
> ä<
Same with % notation:
print( '>%3s<' % ( 'a' ) )
> a<
19 matches
Mail list logo