How to write verbose scripts

Mensanator mensanator at aol.com
Wed Sep 3 00:07:11 CEST 2008


On Sep 2, 4:14 pm, John Machin <sjmac... at lexicon.net> wrote:
> On Sep 3, 3:52 am, Mensanator <mensana... at aol.com> wrote:
>
> > On Sep 2, 11:55 am, Steven D'Aprano <st... at REMOVE-THIS-
>
> >   if (p & 1)==1:
> >     print_evens = True
> >   else:
> >     print_evens = False
> >   if (p & 2)==2:
> >     print_odds = True
> >   else:
> >     print_odds = False
> >   if (p & 4)==4:
> >     print_debug = True
> >   else:
> >     print_debug = False
>
> No, no, no, you've taken "How to write verbose scripts" rather too
> literally; try this:
>
> print_evens = p & 1
> print_odds = p & 2
> print_debug = p & 4

Thanks for that. Luckily, the code only does that once per call.



More information about the Python-list mailing list