[issue24074] string, center, ljust, rjust, width paramter should accept None

2015-04-30 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Marking as rejected because 0 works fine and accepting None just complicates 
the parsing and documentation without any incremental benefit.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24074
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24074] string, center, ljust, rjust, width paramter should accept None

2015-04-29 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Sorry, this use case seems contrived.   The common use case for centering is 
with a known width (otherwise, what is the point).  Also, it isn't hard to 
write something like:
   s.center(w or 0)

--
nosy: +rhettinger
priority: normal - low
type: behavior - enhancement
versions: +Python 3.5 -Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24074
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24074] string, center, ljust, rjust, width paramter should accept None

2015-04-29 Thread Glen Fletcher

New submission from Glen Fletcher:

I've only list python 2.7, as I'm not sure that version 3 doesn't accept None, 
if so this should be changed there too.

If these function are passed None, as the width they should return the string 
unchanged, just as they would for with a width set to 0.

Reasoning, A common use of these would be in list comprehensions and such, i.e. 
(string.center(encode(i), w) for i, w in items, widths), given the that items 
and widths may be of differing length in theory i should be a empty string and 
width 0 it not specified however the best way of dealing with this would be to 
use itertools.izip_longest(items, widths, default=None) and None would be 
encode as No Value, however this would require writing 
(string.center(encode(i), 0 if w is None else w) for i, w in 
itertools.izip_longest(items, widths, default=None)), which is far harder to 
follow, when its quite reasonable to expect these string alignment functions to 
return an unpadded string if passed None as the width.

--
components: Library (Lib)
messages: 242215
nosy: glenflet
priority: normal
severity: normal
status: open
title: string, center, ljust, rjust, width paramter should accept None
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24074
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com