Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-10 Thread Carl Banks
On Feb 9, 7:36 pm, Tim Chase wrote: > Larry Hudson wrote: > > But a minor rearrangement is simpler, and IMHO clearer: > > > if 'mystring' not in s: > >      print 'not found' > > else: > >      print 'foundit' > >      print 'processing' > > I've always vacillated on whether that would better be w

Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-10 Thread Roy Smith
In article , Tim Chase wrote: > Larry Hudson wrote: > > But a minor rearrangement is simpler, and IMHO clearer: > > > > if 'mystring' not in s: > > print 'not found' > > else: > > print 'foundit' > > print 'processing' > > I've always vacillated on whether that would better be w

Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-10 Thread Simon Brunning
On 10 February 2010 03:36, Tim Chase wrote: > Any thoughts on how others make the choice? There are two criteria that I use here. I'll often tend towards the positive test; it's just that little bit easier to comprehend, I think. On the other hand, if one case is overwhelmingly more common, I'll

Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-09 Thread Stephen Hansen
On Tue, Feb 9, 2010 at 7:58 PM, Daniel Stutzbach < dan...@stutzbachenterprises.com> wrote: > On Tue, Feb 9, 2010 at 9:36 PM, Tim Chase > wrote: > >> removing the "not" from the condition. I admit I choose one over the >> other based on some gut-feeling aesthetic that I can't really nail down. I

Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-09 Thread Daniel Stutzbach
On Tue, Feb 9, 2010 at 9:36 PM, Tim Chase wrote: > removing the "not" from the condition. I admit I choose one over the other > based on some gut-feeling aesthetic that I can't really nail down. I think > one of my major influencing factors revolves around the negative "not" > portion having one

Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-09 Thread Cameron Simpson
On 09Feb2010 21:36, Tim Chase wrote: | Larry Hudson wrote: | >But a minor rearrangement is simpler, and IMHO clearer: | > | >if 'mystring' not in s: | > print 'not found' | >else: | > print 'foundit' | > print 'processing' | | I've always vacillated on whether that would better be wri

Re: "if {negative}" vs. "if {positive}" style (was: New to Python)

2010-02-09 Thread Tim Chase
Larry Hudson wrote: But a minor rearrangement is simpler, and IMHO clearer: if 'mystring' not in s: print 'not found' else: print 'foundit' print 'processing' I've always vacillated on whether that would better be written as Larry does, or as if 'mystring' in s print 'f