Python dot-equals (syntax proposal)
jeanmichel at sequans.com
Fri Apr 30 18:50:46 CEST 2010
> At least a few times a day I wish python had the following shortcut
> this would be equivalent to
> vbl = vbl.func(args)
> foo = "Hello world"
> foo.=split(" ")
> print foo
> # ['Hello', 'world']
> and I guess you could generalize this to
> vbl.=[some text]
> vbl = vbl.[some text]
> # temp = temp.children
Useless if you use meaningful names for your variables & attributes.
It may happen that one object attribute refer to an object of the same
type, but it is quite rare that both can share the same name anyway.
Possible use cases:
car = Car()
car = car.wheel # ???
wheel = Car() # ???
wheel = wheel.wheel # ???
currentCar = Car()
currentCar = currentCar.nextCar
The syntax you prose will be applicable on very little assignements (use
case 3). I'm not sure it's worth it.
More information about the Python-list