Underscores in Python numbers

bonono at gmail.com bonono at gmail.com
Sun Nov 20 19:00:37 EST 2005


Peter Hansen wrote:
> bonono at gmail.com wrote:
> > Peter Hansen wrote:
> >
> >>But why would anyone want to create numeric literals for credit card
> >>numbers?
> >>
> > May be for space saving ? But storage space being so cheap, this is not
> > a very good reason, but still a reason.
>
> Space saving where?  Why would you have any credit card numbers stored
> in any application?  Even a credit card company isn't going to write
> code that has the numbers stored as *literals*!
I am not the one asking for it, only guessing the reason and credit
card company does save it in the database. So saving as half byte
numeric(or 64 bit integer) does save a bit of space comparing with
string.

>
> There's only one place I can think of right now where you might want
> that: in automated tests for code that processes credit card numbers.
> And you definitely do not need to "save space" in that situation...
>
That usually don't need it as one big number but usually more easier to
code if treating as string(like checksum), something like:

for digits in cc:
  checksum += int(digits)




More information about the Python-list mailing list