Re: Style question for conditional execution

2010-11-24 Thread Asun Friere
On Nov 25, 7:43 am, Paul Rubin wrote: > Gerald Britton writes: > >     if v: > >         f() > > > I might, however, think more in a functional-programming direction. > > Then I might write: > > >     v and f() > > Python has conditional expressions.  The above would be: > >     f() if v else Non

Re: Style question for conditional execution

2010-11-24 Thread Paul Rubin
Gerald Britton writes: > if v: > f() > > I might, however, think more in a functional-programming direction. > Then I might write: > > v and f() Python has conditional expressions. The above would be: f() if v else None using "and" is bug-prone. -- http://mail.python.org/m

Re: Style question for conditional execution

2010-11-24 Thread Arnaud Delobelle
Gerald Britton writes: > Writing in Python gives me the luxury of choosing different paradigms > for similar operations. Lately I've been thinking about a minor > detail that peaked my interest and am curious what others think: > > Say that I have some function "f" that I will execute if some va

Re: Style question for conditional execution

2010-11-24 Thread Steven Howe
Both paradigms are in the bash shell. Using a test switch (like -x for executiable) mixed with an && or ||. Example: [-x /usr/bin/firefox ] || exit I think it's very clear, to old hands, but not so much for a new or intermediate users. It certainly is the 'cleaner' form. Like the C styl

Re: Style question for conditional execution

2010-11-24 Thread Ed Leafe
On Nov 24, 2010, at 1:46 PM, Gerald Britton wrote: > Say that I have some function "f" that I will execute if some variable > "v" evaluates true. Using a classical procedural approach, I might > write: > >if v: >f() > > I might, however, think more in a functional-programming direct

Re: Style question for conditional execution

2010-11-24 Thread Ian
On Nov 24, 11:46 am, Gerald Britton wrote: > Say that I have some function "f" that I will execute if some variable > "v" evaluates true.  Using a classical procedural approach, I might > write: > >     if v: >         f() > > I might, however, think more in a functional-programming direction. > T

Style question for conditional execution

2010-11-24 Thread Gerald Britton
Writing in Python gives me the luxury of choosing different paradigms for similar operations. Lately I've been thinking about a minor detail that peaked my interest and am curious what others think: Say that I have some function "f" that I will execute if some variable "v" evaluates true. Using