code review

Ben Finney ben+python at benfinney.id.au
Sun Jul 1 03:28:20 EDT 2012


Chris Angelico <rosuav at gmail.com> writes:

> On Sun, Jul 1, 2012 at 10:08 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
> > Thomas Jollans <t at jollybox.de> writes:
> >
> >> My sole point, really, is that "normally", one would expect these two
> >> expressions to be equivalent:
> >>
> >> a < b < c
> >> (a < b) < c
> >
> > What norm gives you that expectation? That's not how those operators
> > work in mathematical notation. I know of no programming language
> > that would give a newcomer to Python that expectation. So where is
> > the norm you're referring to?
>
> C, SQL, REXX, and many other languages.

So, languages without strong typing then. In that case, I revise my
statement: I know of no programming language with strong typing that
would give a newcomer to Python the above expectation.

Since Python does have strong typing, norms about operations from
weakly-typed languages should not be expected to apply.

(Incidentally, PostgreSQL was the SQL implementation I went to, and::

    postgres=# SELECT (1 < 2) < 3;
    ERROR:  operator does not exist: boolean < integer
    LINE 1: SELECT (1 < 2) < 3;
                           ^
    HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

So not all SQL implementations make the mistake of weak typing.)

-- 
 \     “Try adding “as long as you don't breach the terms of service – |
  `\          according to our sole judgement” to the end of any cloud |
_o__)                      computing pitch.” —Simon Phipps, 2010-12-11 |
Ben Finney



More information about the Python-list mailing list