Perl and Python, a practical side-by-side example.

Ben Finney bignose+hates-spam at benfinney.id.au
Sat Mar 3 04:54:27 EST 2007


William Heymann <kosh at aesaeion.com> writes:

> On Saturday 03 March 2007, Ben Finney wrote:
> > Bjoern Schliessmann <usenet-mail-0306.20.chr0n0ss at spamgourmet.com> writes:
> >
> >     if not recs.has_key(piid):      # [1]
> >
> Why not
>
> if piid not in recs:
>
> That is shorter, simpler, easier to read and very slightly faster.

Perhaps if I'd made my posting shorter, simpler, easier to read and
slightly faster, you might have read the footnote to which the '[1]'
referred.

-- 
 \            "Choose mnemonic identifiers. If you can't remember what |
  `\             mnemonic means, you've got a problem."  -- Larry Wall |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list