Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-04 Thread Raymond Hettinger
[Michael O'Keefe] def desired(): pass # IF we had a -- operator which would execute the method at # left but return a ref to object #return [8,9,7,1].sort()--reverse()--pop(0)-- # returns [8,7,1] # return [8,9,7,1].sort()--reverse()--pop(0) # returns 9 # return

[Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Michael O'Keefe
I had an idea on some new functionality I'd like to see offered in the python object class. I did some searching on the list but I wouldn't doubt that someone has proposed something like this before as chaining method calls seems like something folks would want to do. Specifically, I'd like to

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Michael O\'Keefe
Michael O'Keefe mokeefe at okeefecreations.com writes: I kept playing with this since my last post went live and here is a little more thought on these ideas. After sitting with the Zen of Python document ( import this), I'm maybe waffling on my previous post already so I came up with a few more

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread dustin
On Sat, Feb 03, 2007 at 07:01:47PM +, Michael O\'Keefe wrote: Anyhow, just curious for ideas and sparking discussion. ... I haven't been on the list long enough to know, but I would expect that this idea and its relatives have been batted around at least once before. I think a lot of people

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Eduardo \EdCrypt\ O. Padoan
Cool! A way to write big one-liners and break the law of Demeter. Also, this should be a Python-ideas, not a Python-dev Post. -- EduardoOPadoan (eopadoan-altavix::com) Bookmarks: http://del.icio.us/edcrypt Blog: http://edcrypt.blogspot.com Jabber: edcrypt at jabber dot org ICQ: 161480283 GTalk:

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | On Sat, Feb 03, 2007 at 07:01:47PM +, Michael O\'Keefe wrote: | I haven't been on the list long enough to know, but I would expect that this | idea and its relatives have been batted around at least once before. Of course. | I

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Greg Ewing
Michael O'Keefe wrote: I'd like to see a built-in shorthand to allow me to chain method calls even when a method call does not explicity return a reference to the instance of the object (self). def newFunc02(): return NewList([8,9,7,1]).self_('sort').self_('reverse').self_('pop',0) My

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Greg Ewing
[EMAIL PROTECTED] wrote: I think there's room for debate on whether specific list methods that currently return None should instead return the list, although I would definitely consult the archives before entering that fray. Indeed. It's been discussed many times before. It was a deliberate

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Michael Foord
Greg Ewing wrote: Michael O'Keefe wrote: I'd like to see a built-in shorthand to allow me to chain method calls even when a method call does not explicity return a reference to the instance of the object (self). def newFunc02(): return