[Python-Dev] [Python-checkins] r64424 - inpython/trunk:Include/object.h Lib/test/test_sys.pyMisc/NEWSObjects/intobject.c Objects/longobject.cObjects/typeobject.cPython/bltinmodule.c
Steven D'Aprano
steve at pearwood.info
Fri Jun 27 01:34:57 CEST 2008
On Fri, 27 Jun 2008 07:30:43 am Raymond Hettinger wrote:
> The format is already close to the C99 notation
> but replaces the 'p' with '* 2.0 **' which I find to
> be both readable and self-explanatory.
Since we're talking about what's "readable and self-explanatory", I find
that jarring, unexpected, unintuitive, and mathematically bizarre (even
if it is the convention in some areas). It's like writing '123 * A.0
** -2' for 1.23.
And putting spaces around the operators is ugly.
I'd like to mention that what bin() et al is actually doing is not so
much returning a binary number string but returning a hybrid
binary/decimal arithmetic expression. So bin() returns a binary number
string for int arguments, and an expression for float arguments: these
are conceptually different kinds of things, even if they're both
strings.
Frankly, I'd be much happier if the API (whatever it is) returned a
tuple of (binary string, base int, exponent int), and let users write
their own helper function to format it any way they like. Or failing
that, the p notation used by Java and C99. (And yes, mixing decimal
exponents with binary mantissas upsets me too, but somehow it's less
upsetting.)
--
Steven
More information about the Python-Dev
mailing list