Negative precision is an interesting concept. I think this could be very useful!
I think this would be better done through a “margin” field like it’s done in Prefixed. Then it is more flexible and can be applied more generally. For example, moving the boundary from 1000 to 100 would be a margin of -90, since 100 is 90% of 1000. In Prefixed this looks like f'{Float(123.456):%-90h}'
.
I disagree that the user should have to reformat the string, but I do agree that fill on the number and fill on the string are different operations and the current spec is lacking in this area. It would be great if there was a precision-like field for the left of the decimal.
I’m not apposed to this. I almost always add the space for readability.
I’m not apposed to this either, but as @pf_moore indicated, many people use a single capital letter. I agree this is ambiguous and I never know if they mean base-10 or base-2. It would probably be good if the language enforced the standards.
Yes, I did leave this off the original post, but Prefixed does do this and I think it’s important.
I’m torn on this one. In one way it’s simple, but in another, it’s easy to accidentally include two periods when one was intended and not realize it.
Agreed. None of the existing behavior should break. Both for backwards compatibility and to ease people moving from other languages that also derive their format specification from C.
This is an interesting idea! I think it would only make sense if we were to come up with a very functional, yet incompatible specification. I’m not even sure what that would look like, but it would be interesting to think about. Perhaps a new spec could address things like customization.
I don’t think we’re talking a lot of complexity nor a minority of users. Just looking at the number of code examples, questions, and existing PyPI packages that exist indicate the current spec if lacking. Even if we implement a few changes it would reduce downstream complexity and duplication of code.
I think there is still some things to work out. The question is if it make sense to do that in this thread or in a working group. One thing is we should probably break things down into problems and proposed solutions. For example, “The existing format specification does not provide sufficient control of significant digits.” Then the proposals of a new flag or a change to the precision field such as supporting '..'
with examples and pros and cons. We’ll need this for a PEP anyway, but I don’t think there is enough consensus yet for a PEP. However I haven’t really participated in this process before, so I’m not really sure.