Re: bug in ''.format()

2017-11-02 Thread Ken Kundert
Sure enough. There is it, right there in the documentation. I did not read far enough. My bad. Thanks! -Ken -- https://mail.python.org/mailman/listinfo/python-list

Re: bug in ''.format()

2017-11-02 Thread MRAB
On 2017-11-02 21:30, Ken Kundert wrote: I just encountered this: '{:0s}'.format('hello') Traceback (most recent call last): File "", line 1, in ValueError: '=' alignment not allowed in string format specifier The exception goes away if I do not specify a width of the string: '{:s}'.form

bug in ''.format()

2017-11-02 Thread Ken Kundert
I just encountered this: >>> '{:0s}'.format('hello') Traceback (most recent call last): File "", line 1, in ValueError: '=' alignment not allowed in string format specifier The exception goes away if I do not specify a width of the string: >>> '{:s}'.format('hello') 'hello' My reading of the

Re: Bug in format specification in Python 3?

2009-08-11 Thread greg
Robert Dailey wrote: I notice that the '0x' portion is counted in the width, which was specified as 8. This seems wrong to me. Is this by design? If so, why? Yes, it's the total field width. This is consistent with the other formats, in which it includes decimal points, signs, etc. If you don

Re: Bug in format specification in Python 3?

2009-08-11 Thread AggieDan04
On Aug 11, 3:28 pm, Robert Dailey wrote: > Hello, > > According to the Python 3.1 documentation, I can have a format > specification like so: > > print( 'This is a hex number: {:#08x}'.format( 4 ) ) > > This will print: > > This is a hex number: 0x04 > > I notice that the '0x' portion is count

Re: Bug in format specification in Python 3?

2009-08-11 Thread MRAB
Robert Dailey wrote: Hello, According to the Python 3.1 documentation, I can have a format specification like so: print( 'This is a hex number: {:#08x}'.format( 4 ) ) This will print: This is a hex number: 0x04 I notice that the '0x' portion is counted in the width, which was specified a

Bug in format specification in Python 3?

2009-08-11 Thread Robert Dailey
Hello, According to the Python 3.1 documentation, I can have a format specification like so: print( 'This is a hex number: {:#08x}'.format( 4 ) ) This will print: This is a hex number: 0x04 I notice that the '0x' portion is counted in the width, which was specified as 8. This seems wrong t