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


Groups > comp.lang.python > #22169

Re: random number

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.038
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'great.': 0.07; 'parameter': 0.09; 'subject:number': 0.09; 'print': 0.15; '!!!!': 0.16; '10:45': 0.16; 'enigma': 0.16; 'kern': 0.16; 'received:80.91': 0.16; 'received:80.91.229': 0.16; 'received:gmane.org': 0.16; 'received:list': 0.16; 'subject:random': 0.16; 'underlying': 0.16; 'robert': 0.18; 'mon,': 0.18; 'string': 0.18; 'def': 0.20; 'role': 0.20; 'wrote:': 0.21; 'function': 0.22; 'header:In-Reply-To:1': 0.22; 'header :User-Agent:1': 0.23; 'import': 0.24; '>>>': 0.24; 'quite': 0.26; 'tried': 0.26; 'skip:+ 20': 0.27; 'this.': 0.28; 'pm,': 0.28; 'all.': 0.29; 'experienced': 0.31; 'maybe': 0.31; 'earlier': 0.32; 'thanks': 0.34; 'skip:s 20': 0.34; "skip:' 10": 0.35; 'characters': 0.35; 'header:X-Complaints-To:1': 0.36; 'michael': 0.38; 'skip:l 20': 0.38; 'received:org': 0.38; 'expect': 0.39; 'clear': 0.39; 'wanted': 0.39; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'great': 0.60; 'mar': 0.61; 'call': 0.62; 'skip:+ 10': 0.63; 'more': 0.63; 'our': 0.64; 'results': 0.65; 'different': 0.65; 'world': 0.65; '26,': 0.66; 'times': 0.66; 'believe': 0.67; '2012': 0.69; 'one;': 0.84; 'random,': 0.84; 'terrible': 0.84; 'eco': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robert Kern <robert.kern@gmail.com>
Subject Re: random number
Date Mon, 26 Mar 2012 10:50:22 +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>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 94.197.127.115.threembb.co.uk
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20120313 Thunderbird/11.0
In-Reply-To <CABgq=FzwzMRybR9E1seHno3syKikcNT-ZoVhWfbya8YCdkfQgQ@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.991.1332755433.3037.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332755433 news.xs4all.nl 6934 [2001:888:2000:d::a6]:56527
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22169

Show key headers only | 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