Re: How do I chain methods?

2010-10-25 Thread Terry Reedy
On 10/24/2010 11:42 PM, Chris Rebert wrote: On Sun, Oct 24, 2010 at 4:11 PM, James Mills wrote: On Mon, Oct 25, 2010 at 9:02 AM, Chris Rebert wrote: Method chaining is usually* not idiomatic in Python. I don't agree but anyway... I've just not seen it commonly used amongst python programme

Re: How do I chain methods?

2010-10-25 Thread Stefan Schwarzer
Hi Steve and others, On 2010-10-25 06:08, Steve Holden wrote: > On 10/24/2010 11:42 PM, Chris Rebert wrote: >> On Sun, Oct 24, 2010 at 4:11 PM, James Mills >> wrote: >>> I don't agree but anyway... I've just not seen it commonly used >>> amongst python programmers. >> >> If Python wanted to encou

Re: How do I chain methods?

2010-10-24 Thread Steve Holden
On 10/24/2010 11:42 PM, Chris Rebert wrote: > On Sun, Oct 24, 2010 at 4:11 PM, James Mills > wrote: >> On Mon, Oct 25, 2010 at 9:02 AM, Chris Rebert wrote: >>> Method chaining is usually* not idiomatic in Python. >> >> I don't agree but anyway... I've just not seen it commonly used >> amongst pyt

Re: How do I chain methods?

2010-10-24 Thread Chris Rebert
On Sun, Oct 24, 2010 at 4:11 PM, James Mills wrote: > On Mon, Oct 25, 2010 at 9:02 AM, Chris Rebert wrote: >> Method chaining is usually* not idiomatic in Python. > > I don't agree but anyway... I've just not seen it commonly used > amongst python programmers. If Python wanted to encourage metho

Re: How do I chain methods?

2010-10-24 Thread James Mills
On Mon, Oct 25, 2010 at 9:39 AM, James Mills wrote: > Function/Method Chaining is probably used a lot in Python itself: > x = 4 x.__add__(1).__sub__(3) > 2 > > The implementation of many common operators return self (the object > you're working with). My apologies, this was a terribly e

Re: How do I chain methods?

2010-10-24 Thread James Mills
On Mon, Oct 25, 2010 at 12:49 PM, Steven D'Aprano wrote: > ...if you're writing x.__add__(1).__sub__(3) instead of x + 1 - 3 then > you're almost certainly doing it wrong. It was just an example :) ... And this isn't python-tutor --James -- -- James Mills -- -- "Problems are solved by method"

Re: How do I chain methods?

2010-10-24 Thread Steven D'Aprano
On Mon, 25 Oct 2010 09:39:47 +1000, James Mills wrote: > On Mon, Oct 25, 2010 at 9:21 AM, chad wrote: >> I just saw this technique used in python script that was/is used to >> automatically log them in myspace.com. Hence the question. > > Function/Method Chaining is probably used a lot in Python

Re: How do I chain methods?

2010-10-24 Thread Steve Holden
On 10/24/2010 7:39 PM, James Mills wrote: > On Mon, Oct 25, 2010 at 9:21 AM, chad wrote: >> I just saw this technique used in python script that was/is used to >> automatically log them in myspace.com. Hence the question. > > Function/Method Chaining is probably used a lot in Python itself: > >>

Re: How do I chain methods?

2010-10-24 Thread James Mills
On Mon, Oct 25, 2010 at 9:21 AM, chad wrote: > I just saw this technique used in python script that was/is used to > automatically log them in myspace.com. Hence the question. Function/Method Chaining is probably used a lot in Python itself: >>> x = 4 >>> x.__add__(1).__sub__(3) 2 The implement

Re: How do I chain methods?

2010-10-24 Thread chad
On Oct 24, 4:11 pm, James Mills wrote: > On Mon, Oct 25, 2010 at 9:02 AM, Chris Rebert wrote: > > Method chaining is usually* not idiomatic in Python. > > I don't agree but anyway... I've just not seen it commonly used > amongst python programmers. > > cheers > James > I just saw this technique

Re: How do I chain methods?

2010-10-24 Thread James Mills
On Mon, Oct 25, 2010 at 9:02 AM, Chris Rebert wrote: > Method chaining is usually* not idiomatic in Python. I don't agree but anyway... I've just not seen it commonly used amongst python programmers. cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.or

Re: How do I chain methods?

2010-10-24 Thread James Mills
On Mon, Oct 25, 2010 at 8:47 AM, chad wrote: > I tried the following... > > > > #!/usr/bin/python > > class foo: >    def first(self): >        print "Chad " > >    def last(self): >        print "A " > > x = foo() > y = x.first() > y.last() > > But when I ran it, I got the following... > > [cdal.

Re: How do I chain methods?

2010-10-24 Thread Chris Rebert
On Sun, Oct 24, 2010 at 3:47 PM, chad wrote: > How do I chain methods? > I tried the following... > > #!/usr/bin/python > > class foo: >    def first(self): >        print "Chad " > >    def last(self): >        print "A " > > x = foo()

How do I chain methods?

2010-10-24 Thread chad
I tried the following... #!/usr/bin/python class foo: def first(self): print "Chad " def last(self): print "A " x = foo() y = x.first() y.last() But when I ran it, I got the following... [cdal...@localhost oakland]$ ./chain.py Chad Traceback (most recent call last):