[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave's and Matlab's limitations

From: Dimitri Maziuk
Subject: Re: Octave's and Matlab's limitations
Date: Thu, 22 Nov 2012 12:10:21 -0600
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121026 Thunderbird/16.0.2

On 11/21/2012 6:45 PM, Sergei Steshenko wrote:

I like Perl, and I do not write it this way. The example you gave is unfair in
several respects:

Yes, and quite deliberately, too. ;) My point was that to someone who hasn't touched math since Scientific Computing 201 and matlab -- never (we did it in C), e.g. "A([1:2:97 98 99],[1:end-1]) = (B > C);" quoted downthread looks no different from obfuscated perl.

I do spell things out and never use "$_" either (when I have to write perl).

      3     print("The absolute value of", n, "is", -n)
Number? 1 The absolute value of 1 is 1


('The absolute value of', 1, 'is', 1)

So, is it a bug or a feature or an outdated tutorial ?


Apparently fixed it in 3.0 (I use OS python) and can be enabled in some 2.x versions by "import __future__" (that's the "outdated" part).

Basically, print is not a function in 2.x, it's a statement, so () after "print" mean something else. In this context they're confusing (and possibly ambiguous) -- that's the bug part:

- ("foo", "bar") defines a tuple (pair) of strings. Tuple is printed in brackets to show you it's a tuple (that's the "feature" part),

- comma after print's argument means "don't print newline",

- brackets also used as you'd expect: to group expressions.

  print("abs of %d is %d" % (n, -n)),
  print("abs of", n, "is", -n),
mean two different things.

Like I said, python's not great. But whitespace forces people format their code in a more readable shape and if you ever watched cpan try to download and build perl 5.678 because you wanted GD graphs -- and on a non-GNU platform where it fails at 'cc != gcc' -- you get to appreciate "batteries included" standard library. If only they had manifest typing...


reply via email to

[Prev in Thread] Current Thread [Next in Thread]