string formatting with mapping & '*'... is this a bug?

Pierre Fortin pfortin at pfortin.com
Fri Sep 10 18:13:38 EDT 2004


On Fri, 10 Sep 2004 23:39:26 +0200 Alex wrote:

> Pierre Fortin <pfortin at pfortin.com> wrote:

> "Special cases are not special enough to break the rules"...

Touche'


> > > it IS a Python oddity that True+False
> > > equals 1;-).
> > 
> > That's OK with me...  it was True+True equals *1* (OR v. +) that
> > forced me to wrap them with int()'s 
> 
> Nope:
> 
> >>> True+True
> 2
> 
> so I'm not sure what you mean...?

My bad...  burned by operator priority...
               Change=change[float(AdjClose) >= float(Open) +
                             float(AdjClose) == float(Open) ]
should read:
               Change=change[(float(AdjClose) >= float(Open)) +
                             (float(AdjClose) == float(Open)) ]


> So, in production code, I think I'd eschew this cleverness and rather
> take the boilerplate hit.  Simplicity never comes easy to those of us
> who are born with a tortuous mind, but it's still worth striving for!

Amen....  I've been too clever in the past so I'll agree and leave the
boilerplate...

Thanks!
Pierre
-30-



More information about the Python-list mailing list