Re: Doctest failing

2011-09-11 Thread Steven D'Aprano
On Mon, 12 Sep 2011 01:06 pm Chris Angelico wrote: > On Mon, Sep 12, 2011 at 11:37 AM, Ben Finney > wrote: >> Those are only practically the same if you ignore the practical worth of >> a function knowing the name it was defined with. The latter does not >> have that, hence I don't see it as prac

Re: Doctest failing

2011-09-11 Thread Chris Angelico
On Mon, Sep 12, 2011 at 11:37 AM, Ben Finney wrote: > Those are only practically the same if you ignore the practical worth of > a function knowing the name it was defined with. The latter does not > have that, hence I don't see it as practically the same as the former. > I know, but in the conte

Re: Doctest failing

2011-09-11 Thread Ben Finney
Chris Angelico writes: > A lambda is basically a function defined in an expression. For instance: > > def add_one(x): >return x+1 > > is (practically) the same as: > > add_one = lambda x: x+1 Those are only practically the same if you ignore the practical worth of a function knowing the name

Re: Doctest failing

2011-09-11 Thread Chris Angelico
On Mon, Sep 12, 2011 at 4:43 AM, Ethan Furman wrote: > Chris Angelico wrote: >> >> And I'd do this with a lambda, but that's just me. Of course, if your >> logic is more complicated, it makes more sense to keep it in a named >> function, but a single conditional call can fit nicely into a lambda.

Re: Doctest failing

2011-09-11 Thread Ethan Furman
Chris Angelico wrote: On Sat, Sep 10, 2011 at 10:24 PM, Alister Ware wrote: Ignoring the docttests my process would be to process each word & then manually capitalize he 1st word, .I would als0 use a comprehension as makes for cleaner code:- def capitalize(word): if word in small_words:

Re: Doctest failing

2011-09-11 Thread Terry Reedy
On 9/11/2011 7:46 AM, Tigerstyle wrote: Thank you Terry, I went for this solution as it was the easiest for me to understand and comment myself keeping in mind what level I am at right now. Thanks a ton to everyone for sharing so much information and making it easy to read and understand your

Re: Doctest failing

2011-09-11 Thread Tigerstyle
On 11 Sep, 04:12, t...@thsu.org wrote: > On Sep 10, 7:47 am, Peter Otten <__pete...@web.de> wrote: > > > > > > > > > > > Tigerstyle wrote: > > > I'm strugglin with some homework stuff and am hoping you can help me > > > out here. > > > > This is the code: > > > > small_words = ('into', 'the', 'a',

Re: Doctest failing

2011-09-11 Thread Tigerstyle
On 11 Sep, 08:18, Dennis Lee Bieber wrote: > On Sat, 10 Sep 2011 16:25:42 -0700, Dennis Lee Bieber > declaimed the following in > gmane.comp.python.general: > > > > > in the language documentation... It will give you a simple way to know > > if you are looking at the first word. Basically, you wa

Re: Doctest failing

2011-09-11 Thread Tigerstyle
On 10 Sep, 17:56, Chris Angelico wrote: > On Sat, Sep 10, 2011 at 10:24 PM, Alister Ware > > wrote: > > Ignoring the docttests my process would be to process each word & then > > manually capitalize he 1st word, .I would als0 use a comprehension as > > makes for cleaner code:- > > > def capitaliz

Re: Doctest failing

2011-09-11 Thread Tigerstyle
On 10 Sep, 13:43, Mel wrote: > Tigerstyle wrote: > > Hi guys. > > > I'm strugglin with some homework stuff and am hoping you can help me > > out here. > > > This is the code: > > > small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on') > > > def book_title(title): > >     """ Takes a st

Re: Doctest failing

2011-09-11 Thread Tigerstyle
On 10 Sep, 13:50, Thomas Jollans wrote: > On 10/09/11 13:20, Tigerstyle wrote: > > > Hi guys. > > > I'm strugglin with some homework stuff and am hoping you can help me > > out here. > > > All tests are failing even though I am getting the correct output on > > the first two tests. And the last te

Re: Doctest failing

2011-09-11 Thread Tigerstyle
On 10 Sep, 19:59, Terry Reedy wrote: > On 9/10/2011 7:20 AM, Tigerstyle wrote: > > > Hi guys. > > > I'm strugglin with some homework stuff and am hoping you can help me > > out here. > > We appreciate you saying so instead of hiding that this is homework. > > > > > > > > > > > small_words = ('into

Re: Doctest failing

2011-09-10 Thread ting
On Sep 10, 7:47 am, Peter Otten <__pete...@web.de> wrote: > Tigerstyle wrote: > > I'm strugglin with some homework stuff and am hoping you can help me > > out here. > > > This is the code: > > > small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on') > >     new_title = [] > >     title_s

Re: Doctest failing

2011-09-10 Thread Peter Otten
Terry Reedy wrote: > On 9/10/2011 7:47 AM, Peter Otten wrote: > >> You can work around that with a >> flag along these lines >> >> first = True >> for word in title_split: >> if first: >> # special treatment for the first word >> first = False >> else: >> # pu

Re: Doctest failing

2011-09-10 Thread Terry Reedy
On 9/10/2011 7:47 AM, Peter Otten wrote: You can work around that with a flag along these lines first = True for word in title_split: if first: # special treatment for the first word first = False else: # put checks for all words but the first here new_

Re: Doctest failing

2011-09-10 Thread Terry Reedy
On 9/10/2011 7:20 AM, Tigerstyle wrote: Hi guys. I'm strugglin with some homework stuff and am hoping you can help me out here. We appreciate you saying so instead of hiding that this is homework. small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on') def book_title(title):

Re: Doctest failing

2011-09-10 Thread Chris Angelico
On Sat, Sep 10, 2011 at 10:24 PM, Alister Ware wrote: > Ignoring the docttests my process would be to process each word & then > manually capitalize he 1st word, .I would als0 use a comprehension as > makes for cleaner code:- > > def capitalize(word): >    if word in small_words: >        return w

Re: Doctest failing

2011-09-10 Thread Alister Ware
On Sat, 10 Sep 2011 04:20:17 -0700, Tigerstyle wrote: > Hi guys. > > I'm strugglin with some homework stuff and am hoping you can help me out > here. > > This is the code: > > small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on') > > def book_title(title): > """ Takes a string

Re: Doctest failing

2011-09-10 Thread Thomas Jollans
On 10/09/11 13:20, Tigerstyle wrote: > Hi guys. > > I'm strugglin with some homework stuff and am hoping you can help me > out here. > > All tests are failing even though I am getting the correct output on > the first two tests. And the last test still gives me "Of" instead of > "of" Cannot repro

Re: Doctest failing

2011-09-10 Thread Peter Otten
Tigerstyle wrote: > I'm strugglin with some homework stuff and am hoping you can help me > out here. > > This is the code: > > small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on') > new_title = [] > title_split = title.strip().lower().split() > for word in title_split:

Re: Doctest failing

2011-09-10 Thread Mel
Tigerstyle wrote: > Hi guys. > > I'm strugglin with some homework stuff and am hoping you can help me > out here. > > This is the code: > > small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on') > > def book_title(title): > """ Takes a string and returns a title-case string. >

Doctest failing

2011-09-10 Thread Tigerstyle
Hi guys. I'm strugglin with some homework stuff and am hoping you can help me out here. This is the code: small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on') def book_title(title): """ Takes a string and returns a title-case string. All words EXCEPT for small words are mad