Python paradigms

Nick Maclaren nmm1 at cus.cam.ac.uk
Sat Apr 8 04:38:56 EDT 2000


Well, starting to use Python, there are two Algol 68 constructions
that I sorely miss.  Here is an example of them in C:

    if ((x = non_trivial_expression) != NULL) {
        do_something_using_x;
    } elif ((x = another_expression) != NULL) {
        do_something_else_using_x;
    } ...

and:

    x = (a != NULL ? a[i]->weeble : 0) + (b != NULL ? b[i]->wombat : 0)

It is pretty obvious why Python doesn't have the former, but I am
a bit puzzled as to the reason for the lack of the latter.  Or
maybe I just haven't found it yet :-)

However, my main point is that the above constructions clarify some
types of code a great deal.  Creating ad-hoc functions is all very
well, but too many of them (especially trivial ones, used once)
obscure the program considerably.  And please note that the above
constructions are NOT an artifact of my coding style - in what I
am doing, they arise naturally out of the problem.

What paradigms are there for replacing such constructions by?


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



More information about the Python-list mailing list