This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Implementing .= for variable operator
Type: enhancement Stage:
Components: None Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, yos233
Priority: normal Keywords:

Created on 2012-11-28 07:37 by yos233, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg176519 - (view) Author: Erik VanderWerf (yos233) Date: 2012-11-28 07:37
I don't know if this has been suggested before, none of my searches returned anything. Sorry if it has been rejected already.

Anyone who has used Python at least a little bit will know that you can use +=, -=, *=, and /= to apply a change to a variable and store it in the same variable in one step. (a = a + 1) == (a += 1)

Would it be possible to add a fifth operator, .= (period-equals) to apply a method to a variable in one step? ex:

>> a = "SPAM"
>> a .= lower()
>> a
'spam'

It would make code look a lot better, and easier to write for any longer-named variables. I can see where passing a method of an object by itself would cause an error, but might it be possible for the .= to override this?
msg176533 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012-11-28 11:01
Please submit this kind of ideas to the python-ideas mailing list, to trigger a discussion and get valuable feedback:
http://www.python.org/community/lists/#python-ideas-mailing-list
History
Date User Action Args
2022-04-11 14:57:38adminsetgithub: 60771
2012-11-28 11:01:10amaury.forgeotdarcsetstatus: open -> closed

nosy: + amaury.forgeotdarc
messages: + msg176533

resolution: not a bug
2012-11-28 07:37:22yos233create