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


Groups > comp.lang.python > #22169 > unrolled thread

Re: random number

Started byRobert Kern <robert.kern@gmail.com>
First post2012-03-26 10:50 +0100
Last post2012-03-26 10:50 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#22169 — Re: random number

FromRobert Kern <robert.kern@gmail.com>
Date2012-03-26 10:50 +0100
SubjectRe: random number
Message-ID<mailman.991.1332755433.3037.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web