Jim Newton a écrit :
A question that has bothered me ever since looking at python
the first time is that not everything evaluates to something.
I am wondering what is the reason for this. Would making
everying evaluate have caused the langugage to be less
efficient execution-wise? or was it a choice to enforce some
sort of standard?
I've read a few discussions about the fact that there is
no if/then/else operartor.
Wouldn't this problem be easily solved by making the built
in keywords actually be evaluatable.
I.e., x = if something:
expr1
else:
expr2
parentheses would of course be optional as they are for
all expressions.
Python is, by design, an 'instruction-based' language, not an
'expression-based' language. Search this ng for discussions on the
inclusion of ternary operator if you want to learn more about this point...
Now if you're looking for a language pretty similar to Python
(very-hi-level, highly dynamic, interpreted, clean and readable syntax,
friendly and enthusiast communauty etc) where everything's an
expression, you may want to try Ruby. It's not as easy to learn, it as
its own warts too, and it has not yet reached such a 'critical mass' as
Python in terms of libs and communauty, but it's a really nice and
usable language too.
Bruno (who likes both languages...)