Nick Coghlan ncogh...@gmail.com added the comment:
Rejecting this after discussion on python-ideas:
http://mail.python.org/pipermail/python-ideas/2009-March/003423.html
Overview of some of the major objections here:
http://mail.python.org/pipermail/python-ideas/2009-March/003440.html
Matthew Barnett pyt...@mrabarnett.plus.com added the comment:
Just for the record, I wasn't happy with ~= either, and I have no
problem with just forgetting the whole idea.
--
___
Python tracker rep...@bugs.python.org
Jervis Whitley jervi...@gmail.com added the comment:
Hi,
I like this idea.
I've put together a short patch that will implement inline
assignment.
if f() - name:
use(name)
or more powerfully:
if f() - name == 'spam':
usespam(name)
the old syntax if something as x: is still available
Steven D'Aprano st...@pearwood.info added the comment:
Regarding the proposed syntax:
if (f() == 'spam') - name:
newname = name.replace('p', 'h')
Surely that should assign the *bool* result of comparing f()
with 'spam' to name? Doing anything else is opening the door to a
world of pain.
Jervis Whitley jervi...@gmail.com added the comment:
If we allow this, how many of the following will be allowed?
if expr as name: block
while expr as name: block
expr as name # alternative to name = expr
This patch implements your final point:
expr as name (albeit with a nominal '-'
Jervis Whitley jervi...@gmail.com added the comment:
Regarding the proposed syntax:
if (f() == 'spam') - name:
newname = name.replace('p', 'h')
Surely that should assign the *bool* result of comparing f()
with 'spam' to name? Doing anything else is opening the door to a
world of
Matthew Barnett pyt...@mrabarnett.plus.com added the comment:
At the moment binding occurs either right-to-left with =, eg.
x = y
where x is the new name, or left-to-right, eg.
import x as y
where y is the new name.
If the order is to be right-to-left then using as seems to be the
Steven D'Aprano st...@pearwood.info added the comment:
Matthew suggested ~= instead of - or as.
I dislike this because ~= first makes me think of approximately equal
to, and then it makes me think of augmented assignment, and only then
do I remember that although ~ is used in Python for