Why '==' ??
Yermat
loic at fejoz.net
Wed Mar 31 03:44:20 EST 2004
Fuzzyman wrote:
> "Tim Peters" <tim.one at comcast.net> wrote in message news:<mailman.124.1080662765.20120.python-list at python.org>...
>
>>[John Roth]
>>
>>>I believe the earliest versions of Python did use the single equal
>>>sign for comparisons. I don't know why Guido changed it, but
>>>it might be in order to keep his options open.
>>
>>It was to stop ambiguity. This was especially acute at an interactive
>>shell, where guessing what
>>
>>
>>>>>x = y
>>
>>intended often guessed wrong <wink> (it's common to wonder whether two
>>things are equal at a shell prompt). After the change, that became obvious:
>>
>>
>>>>>x = y # assignment
>>>>>x == y # equal?
>>
>> False
>>
>
>
> Despite *all* that...
>
> The lines
>
> if a = 3
> print 'Yeah baby'
>
> are still *unambiguous*.... yet the interpreter refuses to understand
> you......
>
> Theres no reason why a single '=' shouldn't be understood in a
> conditional....
> As for needing a ':' to allow statements after a 'def' or a
> conditional.... python already has the ';' for that... why insist on a
> ':'
>
> Regards,
>
>
> Fuzzy
>
> http://www.voidspace.org.uk/atlantibots/pythonutils.html
Why not !
Stop complain about choice !
If you want another syntax, you can imagine yours.
What you need is rather simple :
Create a parser and an Abstract Syntax Tree from the parser. Then you
can still use python to bytecompile it ( with compiler.pycodegen ).
That way you will be able to use the python library but have your
favorite syntax with brackets, '=' or ':=' assignement, etc...
Also had a hook on the import statement to automatically byte-compile
your file when requested and that's all !
I'm playing with that kind of stuff. That is really fun and easy...
Yermat
More information about the Python-list
mailing list