[issue1714448] if something as x:

2009-03-15 Thread Matthew Barnett
Matthew Barnett 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 ___ _

[issue1714448] if something as x:

2009-03-15 Thread Nick Coghlan
Nick Coghlan 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 -- nosy: +ncoghlan r

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley added the comment: > Matthew suggested ~= instead of -> or "as". Try the patch, you can make changes (for those that aren't aware) by changing the token in Grammar/Grammar to whatever you wish. It is easy to do and you need only recompile after this step. example: assexp:

[issue1714448] if something as x:

2009-03-14 Thread Steven D'Aprano
Steven D'Aprano 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 bitwise-not, ~= is

[issue1714448] if something as x:

2009-03-14 Thread Matthew Barnett
Matthew Barnett 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 best choice. On the

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley 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. You are

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley added the comment: > If we allow this, how many of the following will be allowed? > if expr as name: > while expr as name: > expr as name # alternative to "name = expr" This patch implements your final point: expr as name (albeit with a nominal '->' RARROW rather than 'as')

[issue1714448] if something as x:

2009-03-14 Thread Steven D'Aprano
Steven D'Aprano 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. if (f() == 'spam')

[issue1714448] if something as x:

2009-03-14 Thread Steven D'Aprano
Steven D'Aprano added the comment: What's wrong with this? ob = map[x][y].overpay if ob: ob.blit(x, y) Is this proposal just about saving one line? If we allow this, how many of the following will be allowed? if expr as name: while expr as name: expr as name # alternative to "name = e

[issue1714448] if something as x:

2009-03-14 Thread Jervis Whitley
Jervis Whitley 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 if that is what