Re: Underscores in Python numbers



Dave Hansen <iddw@xxxxxxxxxxx> wrote:
> Of course, I write _far_ more code in C than Python. But I've seen
> enough bugs of the sort where someone wrote 1200000 when they meant
> 12000000, that I see great value in being able to specify 12_000_000.

I'll admit that being able to write 12_000_000 would be convenient.
On the other hand, writing 12 * 1000 * 1000 is almost as clear. In C,
the multiplication would be done at compile time, so it's not even any
less efficient. I'm not sure how Python handles that, but if it
turned out to be a serious run-time performance issue, it's easy
enough to factor it out into something that's done once and stored.

Bottom line, embedded no-op underscores in numbers would be nice (and,
IHMO, should be added), but the lack of such a feature should not be
used as an excuse to write such unreadable monstrosities as 12000000
in source code.

Semi-related: see Jakob Nielsen's complaint about having to enter
credit card numbers as 16-digit strings with no breaks on web forms
(http://www.useit.com/alertbox/designmistakes.html, item #7, last
bullet point).
.



Relevant Pages

  • Re: hardware errors, do C and Forth need different things in hardware?
    ... need or want the sort of complications that this code avoids. ... It's an endless loop that's obviously ... either in software or hardware. ... If it confuses solutions for bugs it will introduce REAL bugs. ...
    (comp.lang.forth)
  • Re: where does GiGi schedule so traditionally, whenever Saeed maintains the civic club very physical
    ... While probes furthermore preach punishments, ... sort at first the straight commissions. ... They are extracting subject to extreme, with blue, sort of lonely ... currently specify the agent. ...
    (sci.crypt)
  • Re: RFID chip barcodes can carry a virus
    ... A quarter of a century later and a lifetime of programming paradigms ... Any unintended behavior in any sort of code (or even most ... hardware and firmware for that matter) can be described as a "bug". ... getting all of what I call bugs out of his software. ...
    (misc.survivalism)
  • Re: Access database records not sorted
    ... Just because you sort and display your data within Access ... Also you need to specify whether your code is using ADO or DAO. ... You'll obviously need to set the database path, table name, ...
    (microsoft.public.word.vba.general)
  • Re: Cohens paper on byte order
    ... function such as "sort" operates in order to have a complete specification. ... correctly when the sort algorithm is applied to a dataset in a one-pass ... to specify internal behavior of the algorithm in certain applications. ...
    (sci.crypt)