[Tutor] Finding the End of a Def?

2009-01-23 Thread Wayne Watson
Title: Signature.html I'm using pythonWin. Is there some way to skip from the start of a def to the end?  How about any similar indentation? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread عماد نوفل
2009/1/23 Emad Nawfal (عماد نوفل) > > > On Fri, Jan 23, 2009 at 8:04 PM, Andre Engels wrote: > >> 2009/1/24 Emad Nawfal (عماد نوفل) : >> > >> > >> > 2009/1/23 Emad Nawfal (عماد نوفل) >> >> >> >> >> >> On Fri, Jan 23, 2009 at 6:57 PM, Andre Engels >> >> wrote: >> >>> >> >>> I made an error in my

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread عماد نوفل
On Fri, Jan 23, 2009 at 8:04 PM, Andre Engels wrote: > 2009/1/24 Emad Nawfal (عماد نوفل) : > > > > > > 2009/1/23 Emad Nawfal (عماد نوفل) > >> > >> > >> On Fri, Jan 23, 2009 at 6:57 PM, Andre Engels > >> wrote: > >>> > >>> I made an error in my program... Sorry, it should be: > >>> > >>> def has

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread Andre Engels
2009/1/24 Emad Nawfal (عماد نوفل) : > > > 2009/1/23 Emad Nawfal (عماد نوفل) >> >> >> On Fri, Jan 23, 2009 at 6:57 PM, Andre Engels >> wrote: >>> >>> I made an error in my program... Sorry, it should be: >>> >>> def hasRoot(word, root): # This order I find more logical >>> loc = 0 >>> for lett

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread عماد نوفل
2009/1/23 Emad Nawfal (عماد نوفل) > > > On Fri, Jan 23, 2009 at 6:57 PM, Andre Engels wrote: > >> I made an error in my program... Sorry, it should be: >> >> def hasRoot(word, root): # This order I find more logical >> loc = 0 >> for letter in root: >> loc = word.find(letter,loc) # I

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread عماد نوفل
On Fri, Jan 23, 2009 at 6:57 PM, Andre Engels wrote: > I made an error in my program... Sorry, it should be: > > def hasRoot(word, root): # This order I find more logical > loc = 0 > for letter in root: > loc = word.find(letter,loc) # I missed the ,loc here... > if loc == -1:

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread Andre Engels
I made an error in my program... Sorry, it should be: def hasRoot(word, root): # This order I find more logical loc = 0 for letter in root: loc = word.find(letter,loc) # I missed the ,loc here... if loc == -1: return false return true # main infile = open("my

Re: [Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread Andre Engels
On Sat, Jan 24, 2009 at 12:02 AM, Emad Nawfal (عماد نوفل) wrote: > Hello Tutors, > Arabic words are build around a root of 3 or 4 consonants with lots of > letters in between, and also prefixes and suffixes. > The root ktb (write) for example, could be found in words like: > ktab : book > mktob: l

[Tutor] finding words that contain some letters in their respective order

2009-01-23 Thread عماد نوفل
Hello Tutors, Arabic words are build around a root of 3 or 4 consonants with lots of letters in between, and also prefixes and suffixes. The root ktb (write) for example, could be found in words like: ktab : book mktob: letter, written wktabhm: and their book yktb: to write lyktbha: in order for hi

Re: [Tutor] Possible to search text file for multiple string values at once?

2009-01-23 Thread W W
On Fri, Jan 23, 2009 at 1:11 PM, Scott Stueben wrote: > Thanks for the help so far - it seems easy enough. To clarify on the > points you have asked me about: > > A sqlite3 database on my machine would be an excellent idea for > personal use. I would like to be able to get a functional script fo

Re: [Tutor] Possible to search text file for multiple string values at once?

2009-01-23 Thread Scott Stueben
Thanks for the help so far - it seems easy enough. To clarify on the points you have asked me about: A sqlite3 database on my machine would be an excellent idea for personal use. I would like to be able to get a functional script for others on my team to use, so maybe a script or compiled progra

Re: [Tutor] class arguments?

2009-01-23 Thread Kent Johnson
Forwarding to the list with my reply... On Fri, Jan 23, 2009 at 1:35 PM, spir wrote: > Le Fri, 23 Jan 2009 06:45:04 -0500, > Kent Johnson a écrit : > >> On Fri, Jan 23, 2009 at 6:04 AM, spir wrote: >> >> > Thank you Alan and sorry for not having been clear enough. The point >> > actually was c

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 11:25 AM, Andre Engels wrote: > On Fri, Jan 23, 2009 at 10:37 AM, amit sethi > wrote: >> so is there a way around that problem ?? > > Ok, I have done some checking around, and it seems that the Wikipedia > server is giving a return code of 403 (forbidden), but still givin

Re: [Tutor] Possible to search text file for multiple string values at once?

2009-01-23 Thread Kent Johnson
On Fri, Jan 23, 2009 at 1:25 PM, Scott Stueben wrote: > I would like to search a text file for a list of strings, like a sql query. What do you want to do if you find one? Do you want to get every line that contains any of the strings, or a list of which strings are found, or just find out if an

Re: [Tutor] Possible to search text file for multiple string values at once?

2009-01-23 Thread W W
On Fri, Jan 23, 2009 at 12:38 PM, bob gailer wrote: > Scott Stueben wrote: > >> Hi all, >> >> I understand that python excels at text processing, and wondered if >> there is a way to use python to accomplish a certain task. >> I would love to set up a script to parse a file and show results fro

Re: [Tutor] Possible to search text file for multiple string values at once?

2009-01-23 Thread bob gailer
Scott Stueben wrote: Hi all, I understand that python excels at text processing, and wondered if there is a way to use python to accomplish a certain task. I am trying to search large text files for multiple strings (like employee ID number, or name). Any text editor (I use Windows mostly) wil

[Tutor] Possible to search text file for multiple string values at once?

2009-01-23 Thread Scott Stueben
Hi all, I understand that python excels at text processing, and wondered if there is a way to use python to accomplish a certain task. I am trying to search large text files for multiple strings (like employee ID number, or name). Any text editor (I use Windows mostly) will certainly have a "fin

Re: [Tutor] Why dictionaries?

2009-01-23 Thread Kent Johnson
On Fri, Jan 23, 2009 at 8:57 AM, Vicent wrote: > A simple but maybe too wide question: > > When is it / isn't it useful to use dictionaries, in a Python program? > I mean, what kind of tasks are they interesting for? Lists are ordered, dicts are not List indices are consecutive integers, dict key

Re: [Tutor] Why dictionaries?

2009-01-23 Thread Alan Gauld
"Vicent" wrote When is it / isn't it useful to use dictionaries, in a Python program? I mean, what kind of tasks are they interesting for? They are interesting for any place where you need to store associations of objects and data. Think of a glossary or an index in a book. Both are a type

Re: [Tutor] Customizing Eclipse text editor

2009-01-23 Thread Alan Gauld
"spir" wrote There should be some research done on this topic. After all, it's a relevant aspect of all programmers' everyday life, no? I suspect there has been - just not in our field. The reason I changed the colours on my web tutor about a year ago was because one of my users who was

[Tutor] Why dictionaries?

2009-01-23 Thread Vicent
A simple but maybe too wide question: When is it / isn't it useful to use dictionaries, in a Python program? I mean, what kind of tasks are they interesting for? Maybe you can give me some references where they explain it. Thank you!! -- Vicent ___ T

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Alan Gauld
"Kent Johnson" wrote Rather than editing the existing code and making it non standard why not subclass robotparser: That won't work, it is urllib.URLOpener() that he is patching and Sorry, yes I misread that post as modifying robotparser, it should have been URLOpener. But... robotparse

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Kent Johnson
On Fri, Jan 23, 2009 at 5:37 AM, Andre Engels wrote: > Looking further I found that a 'cleaner' way to make the same change > is to add to the code of URLopener (outside any method): > > version = '' You can do this without modifying the standard library source, by import urllib urllib.URLop

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Kent Johnson
On Fri, Jan 23, 2009 at 6:23 AM, Alan Gauld wrote: > Rather than editing the existing code and making it non standard > why not subclass robotparser: > > class WP_RobotParser(robotparser): > def __init__(self, *args, *kwargs): > robotparser.__init__(self, *args, *kwargs) > self.

Re: [Tutor] class arguments?

2009-01-23 Thread Kent Johnson
On Fri, Jan 23, 2009 at 6:04 AM, spir wrote: > Thank you Alan and sorry for not having been clear enough. The point actually > was class (definition) attributes. I thought at e.g. Guido's views that lists > were for homogeneous sequences as opposed to tuples rather like records. And > a way to

Re: [Tutor] Customizing Eclipse text editor

2009-01-23 Thread spir
Le Fri, 23 Jan 2009 11:17:15 +0100, Vicent a écrit : > Hello everyone. [...] > As you can see there, I prefer a black background, so I've changed colors a > little. My second question is: do you know any kind of recomended (I mean, > optimized for a good working experience, good for eyes health

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Alan Gauld
"Andre Engels" wrote developers of Wikimedia why this is done, but for now you can resolve this by editing robotparser.py in the following way: In the __init__ of the class URLopener, add the following at the end: self.addheaders = [header for header in self.addheaders if header[0] != "Us

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 12:07 PM, amit sethi wrote: > well thanks ... it worked well ... but robotparser is in urllib isn't there > a module like robotparser in > urllib2 You'll have to ask someone else about that part... -- André Engels, andreeng...@gmail.com _

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread amit sethi
well thanks ... it worked well ... but robotparser is in urllib isn't there a module like robotparser in urllib2 On Fri, Jan 23, 2009 at 3:55 PM, Andre Engels wrote: > On Fri, Jan 23, 2009 at 10:37 AM, amit sethi > wrote: > > so is there a way around that problem ?? > > Ok, I have done some che

Re: [Tutor] class arguments?

2009-01-23 Thread spir
Le Thu, 22 Jan 2009 23:29:59 -, "Alan Gauld" a écrit : > > "Alan Gauld" wrote > > >> is there a way to give arguments to a class definition? > > I see that Kent interpreted your question differently to me. > If you do mean that you want to dynamically define class > attributes rather

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 11:25 AM, Andre Engels wrote: > In the __init__ of the class URLopener, add the following at the end: > > self.addheaders = [header for header in self.addheaders if header[0] > != "User-Agent"] + [('User-Agent', '')] > > (probably > > self.addheaders = [('User-Agent', '')]

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 10:37 AM, amit sethi wrote: > so is there a way around that problem ?? Ok, I have done some checking around, and it seems that the Wikipedia server is giving a return code of 403 (forbidden), but still giving the page - which I think is weird behaviour. I will check with t

[Tutor] Customizing Eclipse text editor

2009-01-23 Thread Vicent
Hello everyone. I work with Eclipse+PyDev. I've managed to customize colors and fonts of the text editor, but I don't know how to change the appearance of the vertical zone that contains folding controls which is next to the line number zone, at the left of the editor window. Here you can see a

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread amit sethi
so is there a way around that problem ?? On Fri, Jan 23, 2009 at 2:25 PM, Andre Engels wrote: > On Fri, Jan 23, 2009 at 9:09 AM, amit sethi > wrote: > > Well that is interesting but why should that happen in case I am using a > > different User Agent because I tried doing > > status=rp.can_fet

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread Andre Engels
On Fri, Jan 23, 2009 at 9:09 AM, amit sethi wrote: > Well that is interesting but why should that happen in case I am using a > different User Agent because I tried doing > status=rp.can_fetch('Mozilla/5.0', > "http://en.wikipedia.org/wiki/Sachin_Tendulkar";) > but even that returns false > Is th

Re: [Tutor] fetching wikipedia articles

2009-01-23 Thread amit sethi
Well that is interesting but why should that happen in case I am using a different User Agent because I tried doing status=rp.can_fetch('Mozilla/5.0', " http://en.wikipedia.org/wiki/Sachin_Tendulkar";) but even that returns false Is there something wrong with the syntax , Is there a catch that i d