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: 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 To: , "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: References: , <1gsdm9-r2c.ln1@crazy-horse.bildanet.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 Roy=2C Per your advise: >>> from base64 import b32encode >>> human_format =3D lambda n: 'Z%s-%s' % (b32encode(chr((n >> 24) & 255) += chr((n >> 16) & 255))[:4]=2C 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 =3D ZKYFA-4PWQ Z17888279480 =3D ZFI4Q-PO4A Z07395350007 =3D ZXDGA-CX3Q Thanks. Andriy ---------------------------------------- > From: roy@panix.com > Subject: Re: How to generate account number? > Date: Sat=2C 3 Nov 2012 09:22:55 -0400 > To: python-list@python.org > > In article =2C > Andriy Kornatskyy wrote: > > > 'Z05738521581' > > 'Z17888279480' > > 'Z07395350007' > > > > Short=2C human readable and satisfy original requirements. > > > > Andriy > > If you really want human readable=2C it's better to chunk the data up int= o > 3 or 4 digit groups. So=2C instead of Z05738521581=2C maybe > Z05-738-521-581. Or perhaps even better=2C Z05-7385-21-581 (just a hunch= =2C > 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=2C but gives you 5 bits/char=2C 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 =