Re: [Tutor] Having trouble with a component of the random module

2008-08-31 Thread Alan Gilfoy
In this case, I was trying to pull 1 card from a 5-card pool, which should have worked. There was a typo in my code that I have since fixed, and it is working. I have to make sure manually that I'm not telling the program to pick more cards than exist in the list. I can do this two ways: Ma

Re: [Tutor] Having trouble with a component of the random module

2008-08-31 Thread Alan Gilfoy
I shouldn't get the same card twice in the same batch, no. Of course, in separate trials, I may get the same card again. Basically, I type the names of relevant cards in a list, and proceed to "tell" my program which list to read, and how many cards to pick from that list. Normally, I put e

Re: [Tutor] Having trouble with a component of the random module

2008-08-31 Thread OmerT
Bob, Kent, I understood all that from the context and yet do not feel familiar enough with the information nor had the time to lookup. The point I'm making is that Alan has a logical problem with his generator regarding the question of repetitive cards in a booster: On one hand, the script does n

Re: [Tutor] Having trouble with a component of the random module

2008-08-31 Thread bob gailer
OmerT wrote: I'm unfamiliar with the random.sample function, yet I can't help but wonder: Do you ever got the same card twice? Quoting the manual: sample( population, k) Return a k length list of unique elements chosen from the population sequence. Used for random sampling without replaceme

Re: [Tutor] Having trouble with a component of the random module

2008-08-31 Thread OmerT
I'm unfamiliar with the random.sample function, yet I can't help but wonder: Do you ever got the same card twice? Is that intentional ? On Thu, Aug 28, 2008 at 6:29 PM, Alan Gilfoy <[EMAIL PROTECTED]> wrote: > Quoting W W <[EMAIL PROTECTED]>: > > >>> The number of items I want from a list is sma

Re: [Tutor] Having trouble with a component of the random module

2008-08-28 Thread Alan Gilfoy
Quoting W W <[EMAIL PROTECTED]>: The number of items I want from a list is smaller than the population (number of items) in the list, so it should work. In this specific case, I'm asking for one item from a five-item list. Are you sure? change this: for card in random.sample(SpecialA, SA):

Re: [Tutor] Having trouble with a component of the random module

2008-08-28 Thread W W
On Thu, Aug 28, 2008 at 1:33 AM, Alan Gilfoy <[EMAIL PROTECTED]>wrote: > > The number of items I want from a list is smaller than the population > (number of items) in the list, so it should work. > > In this specific case, I'm asking for one item from a five-item list. Are you sure? change thi

[Tutor] Having trouble with a component of the random module

2008-08-27 Thread Alan Gilfoy
One of my for-fun Python products is a booster-pack generator for trading card games (specifically, Magic the Gathering, the one game of the genre that I play heavily) Somewhat like baseball cards, the cards in a pack are a somewhat-random selection of cards from the set in question, broken