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