Re: [Tutor] A class list

2010-12-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Robert Berman wrote: I am working on the second part of the 'Bingo' problem defined at the Bingo Praxis web page, http://programmingpraxis.com/2009/02/19/bingo/. My notes as how to best define and build the problem: 'In a large game with five hundred cards in play, wh

Re: [Tutor] A class list

2010-12-24 Thread Noah Hall
Based on what you initally stated, that you would have a list containing 500 numbers, and for each number, there would be a player, using a dict would be ideal. For example, once you've got the winning number, how do you then intend on handling what happens to each player as they win? Do you intend

Re: [Tutor] A class list

2010-12-24 Thread Emile van Sebille
On 12/24/2010 11:09 AM Robert Berman said... 1) Why is the function doing what it is doing rather than what I thought I programmed it to do, you've only got one mycard at the class level that's shared between the instances. and 2) How can I code it to do what I want it to do: Produce N num

Re: [Tutor] A class list

2010-12-24 Thread Robert Berman
From: Noah Hall [mailto:enali...@gmail.com] Sent: Friday, December 24, 2010 2:36 PM To: Robert Berman Subject: Re: [Tutor] A class list Alright, I'll begin by saying that you shouldn't use a list for cards , and a separate one for players. Instead, you should use dictionaries. For example - p

[Tutor] A class list

2010-12-24 Thread Robert Berman
I am working on the second part of the 'Bingo' problem defined at the Bingo Praxis web page, http://programmingpraxis.com/2009/02/19/bingo/. My notes as how to best define and build the problem: 'In a large game with five hundred cards in play, what is the average number of calls required before

Re: [Tutor] Weighted Random Choice - Anyone have an efficientalgorithm?

2010-12-24 Thread Alan Gauld
"Albert-Jan Roskam" wrote Doesn't this qualify as 'monkeying with the loop index'? [*] import random weights = [5, 20, 75] counts = {0:0, 1:0, 2:0} for i in xrange(100): ... i = weighted_choice(weights) # <--- monkeying right here (?) ... counts[i] += 1 Not really because the

Re: [Tutor] Problems processing accented characters in ISO-8859-1 encoded texts

2010-12-24 Thread Steven D'Aprano
Josep M. Fontana wrote: Just one more question. You say that \w means alphanumeric, not just alpha. Is there any expression that would mean "just alpha" and (given the appropriate LOCALE setting) would match 'a' and 'รถ' but not '9'? Unfortunately, I don't think there is a standard code for jus

Re: [Tutor] Weighted Random Choice - Anyone have an efficient algorithm?

2010-12-24 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Albert-Jan Roskam wrote: Hi Steven, Doesn't this qualify as 'monkeying with the loop index'? [*] import random weights = [5, 20, 75] counts = {0:0, 1:0, 2:0} for i in xrange(100): ... i = weighted_choice(weights) #<--- monkeying right here (?) ... counts

Re: [Tutor] Weighted Random Choice - Anyone have an efficient algorithm?

2010-12-24 Thread Albert-Jan Roskam
Hi Steven, Doesn't this qualify as 'monkeying with the loop index'? [*] >>> import random >>> weights = [5, 20, 75] >>> counts = {0:0, 1:0, 2:0} >>> for i in xrange(100): ... i = weighted_choice(weights) # <--- monkeying right here (?) ... counts[i] += 1 [*] http://stackoverflow.com/