Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32702

RE: How to generate account number?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andriy.kornatskyy@live.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'chunk': 0.07; 'subject:How': 0.09; '16)': 0.09; 'base64': 0.09; 'satisfy': 0.09; 'subject:number': 0.09; 'encoding': 0.15; 'sat,': 0.15; 'value.': 0.15; '(just': 0.16; 'advise:': 0.16; 'lambda': 0.16; 'number?': 0.16; 'readable': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'to:name :python-list@python.org': 0.20; 'skip:- 40': 0.21; 'import': 0.21; 'thanks.': 0.21; '3.2': 0.22; 'to:2**1': 0.23; 'header:In-Reply- To:1': 0.25; '(which': 0.26; 'date:': 0.29; 'url:mailman': 0.29; 'character': 0.29; 'maybe': 0.29; "skip:' 10": 0.30; 'url:python': 0.32; 'url:listinfo': 0.32; 'from:addr:live.com': 0.33; 'to:addr :python-list': 0.33; 'nov': 0.35; 'so,': 0.35; 'subject:?': 0.35; 'really': 0.36; 'subject:': 0.36; 'but': 0.36; 'url:org': 0.36; 'characters': 0.36; 'email addr:python.org': 0.36; 'skip:z 10': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'easier': 0.38; 'gives': 0.39; 'instead': 0.39; 'to:addr:python.org': 0.39; 'end': 0.40; 'url:mail': 0.40; 'your': 0.60; 'side': 0.61; 'email name:python-list': 0.62; 'information': 0.63; 'account': 0.67; 'subject:account': 0.74; 'article': 0.78; 'groups.': 0.78; 'email addr:panix.com': 0.84; 'charset:windows-1251': 0.97
X-Originating-IP [213.130.16.2]
From Andriy Kornatskyy <andriy.kornatskyy@live.com>
To <roy@panix.com>, "python-list@python.org" <python-list@python.org>
Subject RE: How to generate account number?
Date Sat, 3 Nov 2012 19:18:09 +0300
Importance Normal
In-Reply-To <roy-1E6B33.09225503112012@news.panix.com>
References <roy-1E6B33.09225503112012@news.panix.com>
Content-Type text/plain; charset="windows-1251"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-OriginalArrivalTime 03 Nov 2012 16:18:10.0058 (UTC) FILETIME=[D0CCE6A0:01CDB9DE]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3244.1351959557.27098.python-list@python.org> (permalink)
Lines 58
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351959557 news.xs4all.nl 6877 [2001:888:2000:d::a6]:49665
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32702

Show key headers only | View raw


Roy,

Per your advise:

>>> from base64 import b32encode
>>> human_format = lambda n: 'Z%s-%s' % (b32encode(chr((n >> 24) & 255) + chr((n >> 16) & 255))[:4], b32encode(chr((n >> 8) & 255) + chr(n & 255))[:4])
>>> human_format(5738521581)
'ZKYFA-4PWQ'
>>> human_format(17888279480)
'ZFI4Q-PO4A'
>>> human_format(7395350007)
'ZXDGA-CX3Q'

Side by side:

Z05738521581 = ZKYFA-4PWQ
Z17888279480 = ZFI4Q-PO4A
Z07395350007 = ZXDGA-CX3Q

Thanks.

Andriy


----------------------------------------
> From: roy@panix.com
> Subject: Re: How to generate account number?
> Date: Sat, 3 Nov 2012 09:22:55 -0400
> To: python-list@python.org
>
> In article <mailman.3234.1351931985.27098.python-list@python.org>,
> Andriy Kornatskyy <andriy.kornatskyy@live.com> wrote:
>
> > 'Z05738521581'
> > 'Z17888279480'
> > 'Z07395350007'
> >
> > Short, human readable and satisfy original requirements.
> >
> > Andriy
>
> If you really want human readable, it's better to chunk the data up into
> 3 or 4 digit groups. So, instead of Z05738521581, maybe
> Z05-738-521-581. Or perhaps even better, Z05-7385-21-581 (just a hunch,
> but I suspect varying the length of the groups makes it easier to read).
>
> Even better might be base-32 encoding the value. Strings of digits have
> an information density of about 3.2 bits/char. Base-32 is just about as
> readable, but gives you 5 bits/char, so you end up with a few less
> characters (which you still want to chunk into 3 or 4 character groups).
> --
> http://mail.python.org/mailman/listinfo/python-list
 		 	   		  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 00:13 +0300
  Re: How to generate account number? GangGreene <GangGreene@example.com> - 2012-11-02 18:02 -0400
    RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 11:38 +0300
      Re: How to generate account number? Roy Smith <roy@panix.com> - 2012-11-03 09:22 -0400
        Re: How to generate account number? Tim Chase <python.list@tim.thechases.com> - 2012-11-03 10:34 -0500
        RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 19:18 +0300
        RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 19:23 +0300
  Re: How to generate account number? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-02 22:39 +0000
    RE: How to generate account number? Andriy Kornatskyy <andriy.kornatskyy@live.com> - 2012-11-03 11:42 +0300

csiph-web