Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

Chris Rebert clp2 at rebertia.com
Sat Feb 20 03:44:10 EST 2010


On Fri, Feb 19, 2010 at 11:17 PM, sjdevnull at yahoo.com
<sjdevnull at yahoo.com> wrote:
> On Feb 20, 1:30 am, Lawrence D'Oliveiro <l... at geek-
> central.gen.new_zealand> wrote:
>> If Python doesn’t distinguish between procedures and functions, why should
>> it distinguish between statements and expressions?
>
> Because the latter are different in Python (and in Ruby

I think your Ruby assertion needs fact-checking:

irb(main):001:0> a = 7  # assignments have a value
=> 7
irb(main):002:0> puts(b = 42)  # as further proof
42
=> nil
irb(main):003:0> b
=> 42
irb(main):004:0> c = [6,4,5]
=> [6, 4, 5]
irb(main):005:0> if false
irb(main):006:1>   c.reverse!
irb(main):007:1> else
irb(main):008:1*   c.sort!
irb(main):009:1> end  # even the if-else control structure has a value
=> [4, 5, 6]
irb(main):010:0> begin # same with exception handling
irb(main):011:1*    raise "a runtime error"
irb(main):012:1> rescue RuntimeError
irb(main):013:1>   "sounds bad"
irb(main):014:1> end
=> "sounds bad"
irb(main):015:0> def foo # and same with method bodies
irb(main):016:1>   99
irb(main):017:1> end
=> nil
irb(main):018:0> foo
=> 99

Quoth Wikipedia regarding Ruby (programming language):
"For practical purposes there is no distinction between expressions
and statements"

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list