Re: [Python-Dev] PEP 3127 (Integer Literal Support and Syntax): %o and %b
Guido van Rossum wrote: On Tue, Mar 18, 2008 at 9:11 PM, Eric Smith [EMAIL PROTECTED] wrote: I've been double checking the PEP 3127 implementation in py3k and the backport I did to 2.6. The PEP says this about the % operator: The string (and unicode in 2.6) % operator will have 'b' format specifier added for binary, and the alternate syntax of the 'o' option will need to be updated to add '0o' in front, instead of '0'. The %b operator was not added to 3.0, so I'll look into doing that in both 2.6 and 3.0 (which I opened as issue 2416). What should be done for '%#o' formatting in 2.6? The above sentence from the PEP implies it should be modified to add '0o' instead of '0', even in 2.6. But that seems like a bad idea to me. Maybe it should stay as-is, but add a -3 warning? Unfortunately, there'd be no way to change your code to get rid of the warning, short of switching to str.format() or adding a __future__ import (shudder). In 3.0, '%#o' already adds the leading '0o'. I think this is such a tiny detail we shouldn't bother with a -3 warning. I agree that in 2.6, %#o should continue to do what it does in 2.5. Can you update the PEP? Done in r61845. Eric. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 3127 (Integer Literal Support and Syntax): %o and %b
On Tue, Mar 18, 2008 at 9:11 PM, Eric Smith [EMAIL PROTECTED] wrote: I've been double checking the PEP 3127 implementation in py3k and the backport I did to 2.6. The PEP says this about the % operator: The string (and unicode in 2.6) % operator will have 'b' format specifier added for binary, and the alternate syntax of the 'o' option will need to be updated to add '0o' in front, instead of '0'. The %b operator was not added to 3.0, so I'll look into doing that in both 2.6 and 3.0 (which I opened as issue 2416). What should be done for '%#o' formatting in 2.6? The above sentence from the PEP implies it should be modified to add '0o' instead of '0', even in 2.6. But that seems like a bad idea to me. Maybe it should stay as-is, but add a -3 warning? Unfortunately, there'd be no way to change your code to get rid of the warning, short of switching to str.format() or adding a __future__ import (shudder). In 3.0, '%#o' already adds the leading '0o'. I think this is such a tiny detail we shouldn't bother with a -3 warning. I agree that in 2.6, %#o should continue to do what it does in 2.5. Can you update the PEP? -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] PEP 3127 (Integer Literal Support and Syntax): %o and %b
I've been double checking the PEP 3127 implementation in py3k and the backport I did to 2.6. The PEP says this about the % operator: The string (and unicode in 2.6) % operator will have 'b' format specifier added for binary, and the alternate syntax of the 'o' option will need to be updated to add '0o' in front, instead of '0'. The %b operator was not added to 3.0, so I'll look into doing that in both 2.6 and 3.0 (which I opened as issue 2416). What should be done for '%#o' formatting in 2.6? The above sentence from the PEP implies it should be modified to add '0o' instead of '0', even in 2.6. But that seems like a bad idea to me. Maybe it should stay as-is, but add a -3 warning? Unfortunately, there'd be no way to change your code to get rid of the warning, short of switching to str.format() or adding a __future__ import (shudder). In 3.0, '%#o' already adds the leading '0o'. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com