Re: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Machin
On Apr 2, 2:10 am, John Posner wrote: > Dennis Lee Bieber presented a code snippet with two consecutive statements > that made me think, "I'd code this differently". So just for fun ... is > Dennis's original statement or my "_alt" statement more idiomatically > Pythonic? Are there even more Pytho

RE: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Posner
>> >    mrkrs_alt2 = filter(lambda b: b > 127 or b in list("\r\n\t"), block) >> > >> >> Never tested my 'pythonicity', but I would do: >> >> def test(b) : b > 127 or b in r"\r\n\t" Oops! Clearly, b in "\r\n\t" is preferable to ... b in list("\r\n\t") You do *not* want to u

Re: Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread bieffe62
On Apr 1, 5:10 pm, John Posner wrote: > Dennis Lee Bieber presented a code snippet with two consecutive statements > that made me think, "I'd code this differently". So just for fun ... is > Dennis's original statement or my "_alt" statement more idiomatically > Pythonic? Are there even more Pytho

Which is more Pythonic? (was: Detecting Binary content in files)

2009-04-01 Thread John Posner
Dennis Lee Bieber presented a code snippet with two consecutive statements that made me think, "I'd code this differently". So just for fun ... is Dennis's original statement or my "_alt" statement more idiomatically Pythonic? Are there even more Pythonic alternative codings? mrkrs = [b for b i