Re: [Tutor] Getting total counts

2010-10-01 Thread Steven D'Aprano
On Sat, 2 Oct 2010 06:31:42 am aenea...@priest.com wrote: > Hi, > > I have created a csv file that lists how often each word in the > Internet Movie Database occurs with different star-ratings and in > different genres. I would have thought that IMDB would probably have already made that informat

Re: [Tutor] (de)serialization questions

2010-10-01 Thread Alan Gauld
"Albert-Jan Roskam" wrote Maybe my main question is as follows: what permanent object is most suitable to store a large amount of entries (maybe too many to fit into the computer's memory), which can be looked up very fast. It depends on the nature of the object and the lookup but in gener

Re: [Tutor] regexp: a bit lost

2010-10-01 Thread Alex Hall
On 10/1/10, Steven D'Aprano wrote: > On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote: >> >> Here is my test: >> >> s=re.search(r"[\d+\s+\d+\s+\d]", l) >> > >> > Try this instead: >> > >> > re.search(r'\d+\s+\D*\d+\s+\d', l) > [...] >> Understood. My intent was to ask why my regexp would match anyth

Re: [Tutor] regexp: a bit lost

2010-10-01 Thread Steven D'Aprano
On Sat, 2 Oct 2010 01:14:27 am Alex Hall wrote: > >> Here is my test: > >> s=re.search(r"[\d+\s+\d+\s+\d]", l) > > > > Try this instead: > > > > re.search(r'\d+\s+\D*\d+\s+\d', l) [...] > Understood. My intent was to ask why my regexp would match anything > at all. Square brackets create a charact

Re: [Tutor] (de)serialization questions

2010-10-01 Thread Lee Harr
>>> I have data about zip codes, street and city names (and perhaps later also >>> of >>> street numbers). I made a dictionary of the form {zipcode: (street, city)} >> >> One dictionary with all of the data? >> >> That does not seem like it will work. What happens when >> 2 addresses have the sam

[Tutor] Getting total counts

2010-10-01 Thread aeneas24
Hi, I have created a csv file that lists how often each word in the Internet Movie Database occurs with different star-ratings and in different genres. The input file looks something like this--since movies can have multiple genres, there are three genre rows. (This is fake, simplified data.)

Re: [Tutor] (de)serialization questions

2010-10-01 Thread Albert-Jan Roskam
Hi Lee, Thanks for your response. Maybe my main question is as follows: what permanent object is most suitable to store a large amount of entries (maybe too many to fit into the computer's memory), which can be looked up very fast. Eventually, I want to create two objects: 1-one to look up str

Re: [Tutor] regexp: a bit lost

2010-10-01 Thread Alex Hall
On 10/1/10, Steven D'Aprano wrote: > On Fri, 1 Oct 2010 12:45:38 pm Alex Hall wrote: >> Hi, once again... >> I have a regexp that I am trying to use to make sure a line matches >> the format: [c*]n [c*]n n >> where c* is (optionally) 0 or more non-numeric characters and n is >> any numeric charact

Re: [Tutor] Coin Toss Problems

2010-10-01 Thread Alan Gauld
"Colleen Glaeser" wrote First, write a function that simulates flipping a coin. This function needs no parameters. When called, it should return either “HEADS” or “TAILS”. Those are strings. That’s *return*, not print. OK, You've done this When that function is working, write another

Re: [Tutor] Coin Toss Problems

2010-10-01 Thread Alan Gauld
wrote This is also a learner's advice, so just give it a shot. In the first function, set HEADS to 0 and TAILS to 0. In general thats good advice but Colleen was explicitly told to return HEADS and TAILS as strings. But using strings doesn't add much complexity overall in this case. Al

Re: [Tutor] regex advise + email validate

2010-10-01 Thread Norman Khine
hi steven, thanks for the in-depth info, yes i am aware that email validation is not full proof until you actually send an email and then validate that you have a response, i guess dnspython helps a little in this respect and integration with OpenID and the like. for my needs i just wanted to find

Re: [Tutor] regex advise + email validate

2010-10-01 Thread Steven D'Aprano
On Fri, 1 Oct 2010 09:34:01 pm Norman Khine wrote: > hello, i have this code > > http://pastie.org/1193091 > > i would like to extend this so that it validates TLD's such as > .travel and .museum, i can do this by changing {2,4} to {2,7} but > this sort of defeats the purpose of validating the corr

Re: [Tutor] regex advise + email validate

2010-10-01 Thread Norman Khine
thanks for the links, i was just looking at the regular-expressions.info site. On Fri, Oct 1, 2010 at 2:07 PM, Christian Witts wrote: > On 01/10/2010 13:34, Norman Khine wrote: >> >> hello, i have this code >> >> http://pastie.org/1193091 >> >> i would like to extend this so that it validates TL

[Tutor] regex advise + email validate

2010-10-01 Thread Norman Khine
hello, i have this code http://pastie.org/1193091 i would like to extend this so that it validates TLD's such as .travel and .museum, i can do this by changing {2,4} to {2,7} but this sort of defeats the purpose of validating the correct email address. are there any python libraries available to

Re: [Tutor] inheritance problem

2010-10-01 Thread ALAN GAULD
> > OOP is a step up from functions its true but you need to work to > > understand it or you will continue to get confused by trivial errors. > > Then appearently I don't work hard enough. > Im still getting confuse by this example. > > I wrote this piece : > > def print_hands(self): >

Re: [Tutor] Coin Toss Problems

2010-10-01 Thread delegbede
This is also a learner's advice, so just give it a shot. In the first function, set HEADS to 0 and TAILS to 0. Then if flip==0, heads=heads+1 Return Heads. Do same for Tails and see if it makes any sense. Regards. Sent from my BlackBerry wireless device from MTN -Original Message- From: Co

Re: [Tutor] Coin Toss Problems

2010-10-01 Thread Erik H.
On Fri, Oct 01, 2010 at 02:49:33 -0500, Colleen Glaeser wrote: > > > First, write a function that simulates flipping a coin. This function needs > no parameters. When called, it should return either “HEADS” or “TAILS”. > Those > are strings. That’s *return*, not print. Looks good, though I

[Tutor] Coin Toss Problems

2010-10-01 Thread Colleen Glaeser
Dear Tutors, I have an assignment for class due in about 6 hours and I've been working on it for about 3 hours already, getting nowhere. My assignment is as follows: In this exercise, you will write several functions and use them in different ways. Follow the specifications; I insist. First,

Re: [Tutor] Connecting my users

2010-10-01 Thread Nitin Pawar
have a look at this http://bytes.com/topic/python/answers/826973-peer-peer-chat-program On Fri, Oct 1, 2010 at 2:49 PM, Timo wrote: > Hello, > > I have the following idea, but no clue how to implement this. > I want my users to be able to connect to other users (with the same > program) and cha

[Tutor] Connecting my users

2010-10-01 Thread Timo
Hello, I have the following idea, but no clue how to implement this. I want my users to be able to connect to other users (with the same program) and chat with them and exchange files. Ideally without server interaction. Now I heard about peer-to-peer and bittorrent protocol etc. But don't know wh

Re: [Tutor] inheritance problem

2010-10-01 Thread Alan Gauld
"Roelof Wobben" wrote The cards are stored in a directory named cards. Correct. So how do you get a card from the collection stored in self.cards? This is not correct. Card is a list and not a directory. See this : self.cards = [] OK, if thats the mistake you made then you made two mis

Re: [Tutor] Mutable Properties

2010-10-01 Thread Alan Gauld
"Chris King" wrote I noticed that when you make a property to represent a mutable value *class Obj(object): prop = property(get, set) test.prop = ['Hello'] Let's be clear, here you are assigning a list object to your property. and then try and use one of its methods. *test.pr

Re: [Tutor] inheritance problem

2010-10-01 Thread Roelof Wobben
>>> >>> I assigned a card by this code : >>> >>> def deal(self, hands, num_cards=999): >>> num_hands = len(hands) >>> for i in range(num_cards): >>> if self.is_empty(): break # break if out of cards >>> card = self.pop() # take the top card >>> hand = hands[i % num_hands] # whose turn is next? >

Re: [Tutor] inheritance problem

2010-10-01 Thread Alan Gauld
"Roelof Wobben" wrote So if the code you copied has an error how should it assign a card? I assigned a card by this code : def deal(self, hands, num_cards=999): num_hands = len(hands) for i in range(num_cards): if self.is_empty(): break # break if out of cards card = self.pop() # take the t

Re: [Tutor] inheritance problem

2010-10-01 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: alan.ga...@btinternet.com; tutor@python.org > Date: Fri, 1 Oct 2010 06:19:29 + > Subject: Re: [Tutor] inheritance problem > > > > > >> To: tutor@python.org >> From: alan.ga...@