PEP 285: Adding a bool type

Lulu of the Lotus-Eaters mertz at gnosis.cx
Mon Apr 8 02:38:20 EDT 2002


ralph at inputplus.demon.co.uk (Ralph Corderoy) wrote previously:
|To calculate the major sort key you might do
|    major = can_be_moved(o) + can_be_sized(o) + can_be_stacked(o) +
|        can_be_coloured(o) + can_be_hidden(o)
|as opposed to
|    major = 0
|    if can_be_moved(o):
|        major += 1
|    if can_be_sized(o):
         [...]

Of course, I'm sure I'll be justly condmened for preferring:

    fs = (can_be_moved, can_be_sized, can_be_stacked,
          can_be_coloured, can_be_hidden)
    major = len([1 for f in fs if f(o)]))

to either :-).

Yours, Lulu...


--
 mertz@   _/_/_/_/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY:_/_/_/_/ v i
gnosis  _/_/                    Postmodern Enterprises         _/_/  s r
.cx    _/_/  MAKERS OF CHAOS....                              _/_/   i u
      _/_/_/_/_/ LOOK FOR IT IN A NEIGHBORHOOD NEAR YOU_/_/_/_/_/    g s






More information about the Python-list mailing list