Re: [Tutor] class method problem

2010-09-27 Thread Joel Goldstick
I looked up the word zoeken -- it means find in English. I looked up the chapter and exercise in the online text "How to think like a computer scientist" Its a good tutorial. I think the OP seems to get confused on basic concepts. Here is my stab at the exercise: #!/usr/bin/env python """This

Re: [Tutor] class method problem

2010-09-27 Thread Dave Angel
On 2:59 PM, Roelof Wobben wrote: Hello, Fine that you are in a arque But can we come back to my problem. How can I take care that test2 can be initialized. Roelof You had this code, and got the following error: class zoeken() : pass def __len__(self): return 0 def __st

Re: [Tutor] class method problem

2010-09-27 Thread Roelof Wobben
Hello, Fine that you are in a arque But can we come back to my problem. How can I take care that test2 can be initialized. Roelof ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscri

Re: [Tutor] class method problem

2010-09-26 Thread David Hutto
On Sun, Sep 26, 2010 at 3:14 AM, Steven D'Aprano wrote: > On Sun, 26 Sep 2010 02:26:25 pm David Hutto wrote: >> On Sat, Sep 25, 2010 at 9:16 PM, Steven D'Aprano > wrote: >> > On Sun, 26 Sep 2010 08:13:23 am David Hutto wrote: >> >> Since I had nothing else to do, but practice, this looks much >>

Re: [Tutor] class method problem

2010-09-26 Thread Steven D'Aprano
On Sun, 26 Sep 2010 02:26:25 pm David Hutto wrote: > On Sat, Sep 25, 2010 at 9:16 PM, Steven D'Aprano wrote: > > On Sun, 26 Sep 2010 08:13:23 am David Hutto wrote: > >> Since I had nothing else to do, but practice, this looks much > >> better: > >> > >> def find(word, search): > >>       if searc

Re: [Tutor] class method problem

2010-09-25 Thread David Hutto
On Sat, Sep 25, 2010 at 9:16 PM, Steven D'Aprano wrote: > On Sun, 26 Sep 2010 08:13:23 am David Hutto wrote: >> Since I had nothing else to do, but practice, this looks much better: >> >> def find(word, search): >>       if search in word: >>               print True >>       else: >>            

Re: [Tutor] class method problem

2010-09-25 Thread Steven D'Aprano
On Sun, 26 Sep 2010 08:13:23 am David Hutto wrote: > Since I had nothing else to do, but practice, this looks much better: > > def find(word, search): > if search in word: > print True > else: > print False For some definition of "better". If I called a fu

Re: [Tutor] class method problem

2010-09-25 Thread Steven D'Aprano
On Sun, 26 Sep 2010 04:15:03 am Roelof Wobben wrote: > Hello, > > I have this code: > > class zoeken() : It is traditional to name classes with an initial capital letter, so Zoeken would be better. > pass What is the point of the "pass" statement there? That does nothing. Why did you put t

Re: [Tutor] class method problem

2010-09-25 Thread David Hutto
Since I had nothing else to do, but practice, this looks much better: def find(word, search): if search in word: print True else: print False word = raw_input('Enter string of letters to search: ' ) search = raw_input('Enter character to find: ')

Re: [Tutor] class method problem

2010-09-25 Thread David Hutto
This is a little better, it returns a if "a" in, or None if using "z": class zoeken() : pass def __len__(self): return 0 def __str__(self): return test2 def find(self, strng, ch, start, stop): index = start

Re: [Tutor] class method problem

2010-09-25 Thread David Hutto
This returns a if "a" in, or -1 if using "z": class zoeken() : pass def __len__(self): return 0 def __str__(self): return test2 def find(self, strng, ch, start, stop): index = start while index < len(st

[Tutor] class method problem

2010-09-25 Thread Roelof Wobben
Hello, Still the same errors Roelof > >> Date: Sat, 25 Sep 2010 19:33:52 +0100 >> Subject: Re: [Tutor] class method problem >> From: andre...@gmail.com >> To: rwob...@hotmail.com >> >> Your method receives 4 argu

[Tutor] class method problem

2010-09-25 Thread Roelof Wobben
Hello, I have this code: class zoeken() : pass def __len__(self): return 0 def __str__(self): return test2 def find(self, strng, ch, start, stop): index = start while index < len(strng) and index < stop: if strng[index] == ch: