New submission from Erik VanderWerf:

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?

----------
components: None
messages: 176519
nosy: yos233
priority: normal
severity: normal
status: open
title: Implementing .= for variable operator
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16567>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to