Why '==' ??
jcarlson at uci.edu
Wed Mar 31 11:52:38 CEST 2004
> if a = 3
> print 'Yeah baby'
> are still *unambiguous*.... yet the interpreter refuses to understand
Oh, the CPython interpreter understands you, it just doesn't like what
you say. I (and I'm sure the majority of other Python users) agree with
the interpreter, your modified syntax leaves something to be desired.
You syntax also /makes ambiguous/ the following currently valid Python
if a == 3: \
If we converted that to /your/ syntax, it would read...
if a = 3 \
Which would get internally translated to...
if a = 3 print "hello"
I don't think it makes sense, and I wouldn't expect an interpreter to
think it makes sense of it either.
> Theres no reason why a single '=' shouldn't be understood in a
Except that it would be a 'special case' when two different syntactical
symbols mean the same thing.
"Special cases aren't special enough to break the rules."
- The Zen of Python, by Tim Peters
> As for needing a ':' to allow statements after a 'def' or a
> conditional.... python already has the ';' for that... why insist on a
Do you even read the docs? Python does not have ';' to allow statements
after a def, Python has ';' because it allows you to place more than one
statement on a single line. That is, it allows...
a = 1;b = 2;c = 3;
/not/ because it allows the absolutely ugly:
def fun(a,b): print a,; print b;
You should note that ':' is placed in syntactically different locations
than ';', because they have syntactically different meanings. ':' means
"there is some scope that is being enclosed", while ';' means "that is
the end of the previous statement".
More information about the Python-list