Re: [Tutor] parse text file

2010-02-02 Thread spir
On Mon, 1 Feb 2010 16:30:02 +0100 Norman Khine wrote: > On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: > > On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: > > > >> thanks, what about the whitespace problem? > > > > \s* will match any amount of whitespace includin newlines. > > thank y

[Tutor] callable objects

2010-02-02 Thread sudhir prasad
hi, in my porgram i have two modules say module 1 and module 2,module 2 consists of two sub modules say sm1 and sm2, i run module1 ,first it calls sm1 in module 2 and a list gets updated,now i again pass the same list to sm2 in module2 but im getting an error " 'list' object is not callable" so i w

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
thanks denis, On Tue, Feb 2, 2010 at 9:30 AM, spir wrote: > On Mon, 1 Feb 2010 16:30:02 +0100 > Norman Khine wrote: > >> On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: >> > On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: >> > >> >> thanks, what about the whitespace problem? >> > >> >

Re: [Tutor] callable objects

2010-02-02 Thread Alan Gauld
"sudhir prasad" wrote i run module1 ,first it calls sm1 in module 2 and a list gets updated,now i again pass the same list to sm2 in module2 but im getting an error " 'list' object is not callable" That suggests that somewhere in your code you are trying to call the list. ie putting parent

Re: [Tutor] parse text file

2010-02-02 Thread Stefan Behnel
Norman Khine, 02.02.2010 10:16: > get_record = re.compile(r"""openInfoWindowHtml\(.*?\\ticon: myIcon\\n""") > get_title = re.compile(r"""(.*)<\/strong>""") > get_url = re.compile(r"""a href=\"\/(.*)\">En savoir plus""") > get_latlng = re.compile(r"""GLatLng\((\-?\d+\.\d*)\,\\n\s*(\-?\d+\.\d*)\)""")

Re: [Tutor] parse text file

2010-02-02 Thread Dave Angel
Norman Khine wrote: thanks denis, On Tue, Feb 2, 2010 at 9:30 AM, spir wrote: On Mon, 1 Feb 2010 16:30:02 +0100 Norman Khine wrote: On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: thanks, what about the whi

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: > here are the changes: > > import re > file=open('producers_google_map_code.txt', 'r') > data =  repr( file.read().decode('utf-8') ) Why do you use repr() here? > get_record = re.compile(r"""openInfoWindowHtml\(.*?\\ticon: myIcon\\n""") > get

[Tutor] how to pass data to aother function from a class?

2010-02-02 Thread Zheng Jiekai
I'm beginning my python learning. My python version is 3.1 I‘v never learnt OOP before. So I'm confused by the HTMLParser Here's the code: >>> from html.parser import HTMLParser >>> class parser(HTMLParser): def handle_data(self, data): print(data) >>> p = parser() >>> page = """TitleI'

Re: [Tutor] tracking program

2010-02-02 Thread Philip Kilner
Hi Luis, Luis Ortega wrote: > I am fairly new to programming (which means I have never, ever, ever > written a program). I have a book or two in Python, and so far I like > it. I have a stupid question to ask; Is it possible to write an > employee's internet tracking program in Python? > Wayn

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
hello, thank you all for the advise, here is the updated version with the changes. import re file = open('producers_google_map_code.txt', 'r') data = repr( file.read().decode('utf-8') ) get_records = re.compile(r"""openInfoWindowHtml\(.*?\\ticon: myIcon\\n""").findall get_titles = re.compile(r"""

Re: [Tutor] how to pass data to aother function from a class?

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 8:04 AM, Zheng Jiekai wrote: > I'm beginning my python learning. My python version is 3.1 > > I‘v never learnt OOP before. > So I'm confused by the HTMLParser > > Here's the code: from html.parser import HTMLParser class parser(HTMLParser): > def handle_data(self,

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: > On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: >> On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: >> >>> here are the changes: >>> >>> import re >>> file=open('producers_google_map_code.txt', 'r') >>> data =  repr( file.read().decode

[Tutor] Shashwat Anand you helped with search

2010-02-02 Thread jim serson
I am trying to have the search return several numbers or words in a single sentences now. I don't know if I am using the wrong format I am trying to use the split method because I thought I could return several parts of a sentence with it. For example if it had 1 2 3 4 5 I thought I could sear

[Tutor] Question about importing

2010-02-02 Thread Григор
Hi all. How can I import a module which is located in the upper directory. -- Криле имат само тия, дето дето сърцето им иска да лети ! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman

Re: [Tutor] Question about importing

2010-02-02 Thread David Hutto
--- On Tue, 2/2/10, Григор wrote: From: Григор Subject: [Tutor] Question about importing To: "Python Tutor" Date: Tuesday, February 2, 2010, 12:07 PM Hi all. How can I import a module which is located in the upper directory. I think the following might be what you're looking for: http://d

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
On Tue, Feb 2, 2010 at 4:19 PM, Kent Johnson wrote: > On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: >> On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: >>> On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: >>> here are the changes: import re file=open('producers_g

Re: [Tutor] Shashwat Anand you helped with search

2010-02-02 Thread Alan Gauld
"jim serson" wrote I think I am using the right method in the wrong way. I'm not sure what you expect this to do... If you could tell me if I am trying the correct method or give me a push in the right direction that would be grate thanks. Maybe a push... look_in = raw_input ("Enter th

Re: [Tutor] Question about importing

2010-02-02 Thread Grigor Kolev
В 10:33 -0800 на 02.02.2010 (вт), David Hutto написа: > > > --- On Tue, 2/2/10, Григор wrote: > > From: Григор > Subject: [Tutor] Question about importing > To: "Python Tutor" > Date: Tuesday, February 2, 2010, 12:07 PM > > Hi all. >

Re: [Tutor] Question about importing

2010-02-02 Thread David Hutto
--- On Tue, 2/2/10, Grigor Kolev wrote: From: Grigor Kolev Subject: Re: [Tutor] Question about importing To: "David Hutto" Cc: "Python Tutor" Date: Tuesday, February 2, 2010, 2:28 PM В 10:33 -0800 на 02.02.2010 (вт), David Hutto написа: > > > --- On Tue, 2/2/10, Григор wrote: >         

Re: [Tutor] Question about importing

2010-02-02 Thread Grigor Kolev
В 11:47 -0800 на 02.02.2010 (вт), David Hutto написа: > > > --- On Tue, 2/2/10, Grigor Kolev wrote: > > From: Grigor Kolev > Subject: Re: [Tutor] Question about importing > To: "David Hutto" > Cc: "Python Tutor" > Date: Tuesday, February 2, 201

Re: [Tutor] Question about importing

2010-02-02 Thread Eike Welk
On Tuesday February 2 2010 20:28:03 Grigor Kolev wrote: > Can I use something like this > #-- > import sys > sys.path.append("/home/user/other") > import module > #- > Yes I think so. I just tried some

Re: [Tutor] Question about importing

2010-02-02 Thread David Hutto
--- On Tue, 2/2/10, Grigor Kolev wrote: From: Grigor Kolev Subject: Re: [Tutor] Question about importing To: "David Hutto" Cc: "Python Tutor" Date: Tuesday, February 2, 2010, 2:54 PM В 11:47 -0800 на 02.02.2010 (вт), David Hutto написа: > > > --- On Tue, 2/2/10, Grigor Kolev wro

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 1:39 PM, Norman Khine wrote: > On Tue, Feb 2, 2010 at 4:19 PM, Kent Johnson wrote: >> On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: >>> On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine wrote: Why do you use

Re: [Tutor] tracking program

2010-02-02 Thread GOW524
All of you guys rock, I have so much to learn before I even attempt to work on my program. Thank you again for all your help. Luis On Feb 2, 2010 4:49am, Philip Kilner wrote: Hi Luis, Luis Ortega wrote: > I am fairly new to programming (which means I have never, ever, ever > writt

Re: [Tutor] parse text file

2010-02-02 Thread Norman Khine
On Tue, Feb 2, 2010 at 10:11 PM, Kent Johnson wrote: > On Tue, Feb 2, 2010 at 1:39 PM, Norman Khine wrote: >> On Tue, Feb 2, 2010 at 4:19 PM, Kent Johnson wrote: >>> On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine wrote: On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson wrote: > On Tue, Feb 2

Re: [Tutor] Question about importing

2010-02-02 Thread Dave Angel
Eike Welk wrote: On Tuesday February 2 2010 20:28:03 Grigor Kolev wrote: Can I use something like this #-- import sys sys.path.append("/home/user/other") import module #- Yes I think so. I

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 4:56 PM, Norman Khine wrote: > On Tue, Feb 2, 2010 at 10:11 PM, Kent Johnson wrote: >> Try this version: >> >> data = file.read() >> >> get_records = re.compile(r"""openInfoWindowHtml\(.*?\ticon: >> myIcon\n""", re.DOTALL).findall >> get_titles = re.compile(r"""(.*)<\/stro

Re: [Tutor] Question about importing

2010-02-02 Thread Alan Gauld
"Grigor Kolev" wrote Can I use something like this #-- import sys sys.path.append("/home/user/other") import module #- Yes but if you have a lot of modules in there that you might want to use in

[Tutor] help with random.randint

2010-02-02 Thread David
Hello list, I thought this was easy even for me, but I was wrong, I guess. Here is what I want to do: take two random numbers between 1 and 99, and put them into a list. import random terms = [] for i in range(2): terms = random.randint(1, 99) print terms This prints just one number

Re: [Tutor] help with random.randint

2010-02-02 Thread Benno Lang
On Wed, Feb 3, 2010 at 12:21 PM, David wrote: > Hello list, > > I thought this was easy even for me, but I was wrong, I guess. > Here is what I want to do: take two random numbers between 1 and 99, and put > them into a list. > > import random > terms =  [] > for i in range(2): >        terms = ra

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-02 Thread David
Hello Benno, list, thanks for those clarifications, which, well, clarify things ;-) This is my latest creation: import random def createTerms(): terms = [] for i in range(2): terms.append(random.randint(1, 99)) j = terms[0] k = terms[1] print "%3d\nx%2d" % (j, k)

Re: [Tutor] help with random.randint

2010-02-02 Thread bob gailer
David wrote: Hello list, I thought this was easy even for me, but I was wrong, I guess. Here is what I want to do: take two random numbers between 1 and 99, and put them into a list. [snip] Or you can use list comprehension: terms = [random.randint(1, 99) for i in range(2)] or if you seek

Re: [Tutor] help with random.randint

2010-02-02 Thread David
Hello Bob, thanks for your comments! On 03/02/10 14:51, bob gailer wrote: or if you seek terseness: terms = [random.randint(1, 99) for i in 'ab'] Do I understand correctly that 'ab' here merely serves to produce a 'dummy sequence' over which I can run the for loop? David __

Re: [Tutor] help with random.randint (cont. -- now: pseudo code)

2010-02-02 Thread bob gailer
David wrote: [snip] My suggestion (untested): MAX = 12 NQ = 20 # of questions to ask # create a 2 dimensional array of 1's row = [1]*MAX pool = [row[:] for i in range(MAX)] incorrect = [] # store incorrectly answered combos here def askQuestions(): # generate and ask questions: for i in r