[Tutor] Contents of Tutor digest, help with Hangman program

John Palmer speederpython at gmail.com
Mon Jul 19 13:37:25 CEST 2010


Hi Alan thanks for the help. I did try the getpass module, I think I used:

getpass.getpass()

This actually prompted the user to enter a password, which isn't really what
I want. Unless there's something i'm missing with this module? I'll take
another look anyway.




On 19 July 2010 11:00, <tutor-request at python.org> wrote:

> Send Tutor mailing list submissions to
>        tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>        tutor-request at python.org
>
> You can reach the person managing the list at
>        tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>   1. Re: A file containing a string of 1 billion random digits.
>      (Richard D. Moores)
>   2. Re: Help with Hangman program (Alan Gauld)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 19 Jul 2010 02:17:48 -0700
> From: "Richard D. Moores" <rdmoores at gmail.com>
> To: bob gailer <bgailer at gmail.com>
> Cc: tutor at python.org
> Subject: Re: [Tutor] A file containing a string of 1 billion random
>        digits.
> Message-ID:
>        <AANLkTimFilAk6VSxwaUb4ZP_XI_Qdxy7ItK9stldNQXC at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On Sun, Jul 18, 2010 at 11:07, bob gailer <bgailer at gmail.com> wrote:
>
> > Check this out:
> >
> > import random, time
> > s = time.time()
> > cycles = 1000
> > d = "0123456789"*100
> > f = open("numbers.txt", "w")
> > for i in xrange(n):
> >  l = []
> >  l.extend(random.sample(d, 1000))
> >  f.write(''.join(l))
> > f.close()
> > print time.time() - s
> >
> > 1 million in ~1.25 seconds
> >
> > Therefore 1 billion in ~21 minutes. 3 ghz processor 2 g ram.
> >
> > Changing length up or down seems to increase time.
>
> Putting "cycles" where you have "n",  I used
>
> import random, time
> s = time.time()
> cycles = 1000000
> d = "0123456789"*100
> f = open("/p31working/Data/1billion_digits_rand_num_Gailor.txt", "w")
> for i in range(cycles):
>    l = []
>    l.extend(random.sample(d, 1000))
>    f.write(''.join(l))
> f.close()
> print(time.time() - s)
>
> to get 1 billion random digits into a file in 932 seconds (15.6
> minutes).  <http://tutoree7.pastebin.com/Ldh6SX3q>, which uses Steve
> D'Aprano's random_digits function, took 201 seconds (3.35 minutes).
>
> Still, I understand yours, and not his (the return line). I'd never
> noticed random.sample() before, nor tried out extend() on a list.  So
> thanks, Bob.
>
> Dick
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 19 Jul 2010 10:20:58 +0100
> From: "Alan Gauld" <alan.gauld at btinternet.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Help with Hangman program
> Message-ID: <i215dm$miv$1 at dough.gmane.org>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
>        reply-type=original
>
>
> "John Palmer" <speederpython at gmail.com> wrote
>
> > I have the program working nearly as I want it to be. The only
> > problem is,
> > that when the user is prompted to enter its chosen word, (I am using
> > a raw
> > input) and the word is typed in, it shows in the line above,
>
> Take a look at the getpass module.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 77, Issue 68
> *************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100719/ff9baab2/attachment.html>


More information about the Tutor mailing list