Why '==' ??

Fuzzyman michael at foord.net
Thu Apr 1 02:18:32 EST 2004


Josiah Carlson <jcarlson at uci.edu> wrote in message news:<c4e4j9$dtp$1 at news.service.uci.edu>...
> > if a = 3 
> >    print 'Yeah baby'
> > 
> > are still *unambiguous*.... yet the interpreter refuses to understand
> > you......
> 
> 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 
> syntax...
> 
> if a == 3: \
>      print "hello"
> 
> If we converted that to /your/ syntax, it would read...
> 

Not at all...but there you go... you need to reread what I said :-)

> if a = 3 \
>      print "hello"
> 
> 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
> > conditional....
> 
> 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
> 

Not at all.
No need for a special case. Leave '==' with the same meaning as it
currently has... but give '=' a dual meaning (as it has in reality)
with the meaning obvious from context. In 'multi statements' (or
whatever the correct phrase is to pre-empt any more otiose comments)
require '==' so the syntax is clear.

Ie. If the meaning is obvious.... '=' can replace '=='... if it's
not.. it can't...



> > 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?  

Sorry.. didn't realise memorising the entire python documentation was
a requirement before posting :p

> Python does not have ';' to allow statements 

Actually - *you've* completely misread the sense of what I've written
;-)

> after a def, Python has ';' because it allows you to place more than one 
> statement on a single line.  

Yup. 

> 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", 

Which is unnecessary *as far as I can see* - because it's always
obvious that some scope is being enclosed......... You've failed to
show any case where that's not true. (Although I wouldn't be surprised
if it was..).

The reason some people stated it was necessary was to allow another
statement on the same line... which is what I said ';' was for.

Sorry if you enjoy flaming newbies....... but in this case you'r a bit
off beam Josian old bean.............


Regards,



Fuzzy
(Recent python convert)
http://www.voidspace.org.uk/atlantibots/pythonutils.html


> while ';' means "that is 
> the end of the previous statement".
> 
> 
>   - Josiah



More information about the Python-list mailing list