Python paradigms

Oleg Broytmann phd at phd.russ.ru
Sun Apr 9 11:12:30 EDT 2000


On Sun, 9 Apr 2000, Robert W. Cunningham wrote:
>  blah = (((test and [true]) or [false])[0])             # blah = (test ?
> true : false)
> 
> Works for me!  Only if I have a good reason to suspect a problem in this
> particular line of code will I have to look past the comment.

   There is no problem in this particular line, but you'll have plenty of
them if you'd try to use this paradigm:

   blah = ((foo() and [poo()]) or [boo()])[0]

   In C, "foo() ? poo() : boo()" will not call boo() if foo() returns true;
but in Python, you'll have a side-effect of calling boo() even if foo()
returns true - what is wrong, usually.

> Are there ANY Python programmers who don't also know at least this much C?

   I am. I came to Python after 10 years of Borland Pascal and no C. Firest
I tryied Perl, but was very unsuccessful writing my programs; then tryied
Python - and voila! - I use Python for over 4 years and don't see a need to
change anything! :)
   I learned C after Python ('cause I switched from DOS to UNIX the same
time I turned from BPascal to Perl or Python). And still don't know much C.

Oleg.            (All opinions are mine and not of my employer)
---- 
    Oleg Broytmann      Foundation for Effective Policies      phd at phd.russ.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list