Add a limit to string.zfill
so it will raise an error to lengths bigger that the int in the brackets
#120350
Labels
type-feature
A feature request or enhancement
Feature or enhancement
Proposal:
In the
string.zfill()
function, it won't process string-numbers (e.g.:"1234"
) with a length bigger than the input int.This is WEIRD. the zfill value is 4, but the length is 6. It should raise an error.
ValueError
, probably.Only thing: it didn't.
Sometimes when processing datasets, we have to align the digits. However, with this, we can't know if we actually did it right. For example, str.zfill(4) works for most but 1 value in a dataset. We won't be able to know that. (C'mon, no one want's to bother using max(len(dataset[column])) everytime, right?) Raising an error is straightforward.
Example:
ValueError: Your zfill value is {num}, but the max length is {max_len}, which is bigger.
There u go, fast, straightforward, easy-to-fix.
:)
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: