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


Groups > comp.lang.python > #22169

Re: random number

From Robert Kern <robert.kern@gmail.com>
Subject Re: random number
Date 2012-03-26 10:50 +0100
References <CABgq=FyhR+Ldujj3YKRBpVXRVoeoayuXZviUUcNx-gXnFiHLSw@mail.gmail.com> <20120326064000.GB19865@terra.cms.at> <CABgq=FwMuHR1nJiaCDiTJAE4Y_3y6WRhZ2DOMaYYC=ex_gT93g@mail.gmail.com> <20120326092403.GB22725@terra.cms.at> <CABgq=FzwzMRybR9E1seHno3syKikcNT-ZoVhWfbya8YCdkfQgQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.991.1332755433.3037.python-list@python.org> (permalink)

Show all headers | View raw


On 3/26/12 10:45 AM, Nikhil Verma wrote:
> Hi
>
> Thanks Michael I want exactly wanted this. Great !!!!
> def random_number(id)
> ...    characters = list(string.ascii_lowercase +string.ascii_uppercase
> +string.digits)
>
> I used this this earlier and tried then by using choice .
> This is great.

Note that the id parameter is not used by the function at all. If you call this 
function multiple times with the same input, you will get different results each 
time. Is that what you want? What role did you expect the id parameter to play?

> On Mon, Mar 26, 2012 at 2:54 PM, Michael Poeltl <michael.poeltl@univie.ac.at
> <mailto:michael.poeltl@univie.ac.at>> wrote:
>     It's still not quite clear to me what role 'id' is playing ... so let's
>     check this one;
>     and Steven, who is maybe more experienced than I am will help us ufrther
>
>      >>> import random, string
>      >>> def random_number(id):
>     ...     characters = list(string.ascii_lowercase +
>     ...                       string.ascii_uppercase +
>     ...                       string.digits)
>     ...     coll_rand = []
>     ...     for i in range(6):
>     ...         random.shuffle(characters)
>     ...         coll_rand.append(characters[0])
>     ...     return ''.join(coll_rand)
>     ...
>      >>> id = 5
>      >>> print (random_number(id))
>     puMHCr
>      >>>

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

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


Thread

Re: random number Robert Kern <robert.kern@gmail.com> - 2012-03-26 10:50 +0100

csiph-web