C-like assignment expression?

inhahe inhahe at gmail.com
Wed May 21 12:50:37 EDT 2008


>>
>> One thing I hate from C is the assignment in expressions...Forcing
>> myself to write
>> 0 == Something
>> rather than
>> Something == 0
>
> interesting trick, i've never thought of that/seen it
> although if Python implemented it I think it should default to giving 
> warnings when you use = in an expression, that way you don't have to 
> worry.
>

That introduces complications though, do you want to see a pagefull of 
warnings every time you import a module that uses the ='s?
You could specify in your python file that you want to suppress that 
warning, but then you'd never know when you used = by accident when you 
meant to use ==.
anyway i was thinking you could have a second assignment operator to use 
just in expressions, and only allow that.  it could be := since some 
languages tend to use that. i wouldn't like it as a general assignment 
operator but assignment in expressions is a special case.   also <- or ->. 
C uses -> for functions but I think math/calculators use that for 
assignment.







More information about the Python-list mailing list