Hay I got a better idea. If you put two dots (..) on a line by itself it means execute the previous line again!
On 1 May 2010 07:08, Patrick Maupin <pmau...@gmail.com> wrote: > On Apr 30, 11:04 am, Jabapyth <jabap...@gmail.com> wrote: > > At least a few times a day I wish python had the following shortcut > > syntax: > > > > vbl.=func(args) > > > > this would be equivalent to > > > > vbl = vbl.func(args) > > > > example: > > > > foo = "Hello world" > > foo.=split(" ") > > print foo > > # ['Hello', 'world'] > > > > and I guess you could generalize this to > > > > vbl.=[some text] > > # > > vbl = vbl.[some text] > > > > e.g. > > > > temp.=children[0] > > # temp = temp.children[0] > > > > thoughts? > > First thought: good luck getting something like this through. > Probably not going to happen, although I do find the idea very > intriguing. > > Second thought: I don't like the proposed syntax at all. > > +=, -=, /=, *=, etc. conceptually (and, if lhs object supports in- > place operator methods, actually) *modify* the lhs object. > > Your proposed .= syntax conceptually *replaces* the lhs object > (actually, rebinds the lhs symbol to the new object). > > If this were to be deemed worthy of the language, I would think a > better syntax would be something like: > > mystring = .upper() > mystring = .replace('a', 'b') > > etc. > > The '=' shows clearly that mystring is being rebound to a new object. > > As Steven has shown, '.' functions as an operator, so if this change > were accepted, in reality you would probably be able to write: > > mystring = . upper() > mystring=.upper() > > or whatever. But the canonical form would probably be with a space > before the period but not after. > > Regards, > Pat > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list