Re: Documentation, assignment in expression.

2012-03-25 Thread mwilson
Tim Chase wrote: > On 03/25/12 08:11, Chris Angelico wrote: >> On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase >> wrote: >>> Granted, this can be turned into an iterator with a yield, making the >>> issue somewhat moot: >> >> No, just moving the issue to the iterator. Your iterator has exactly >> th

Re: Documentation, assignment in expression.

2012-03-26 Thread mwilson
Dennis Lee Bieber wrote: > On Sun, 25 Mar 2012 19:09:12 -0400, mwil...@the-wire.com declaimed the > following in gmane.comp.python.general: > > >> Most of my database programs wind up having the boilerplate (not tested): >> >> def rowsof (cursor): >> names = [x[0] for x in cursor.descriptio

Re: string interpolation for python

2012-04-02 Thread mwilson
Yingjie Lan wrote: > Seems you miss understood my notion of dynamic string. > Dynamic strings are expressions in disguise: the things > in between $...$ are plain old expressions (with optional > formatting specifications). They are evaluated > as if they were outside the dynamic string. In that

Re: string interpolation for python

2012-04-02 Thread mwilson
mwil...@the-wire.com wrote: > Yingjie Lan wrote: >> Seems you miss understood my notion of dynamic string. >> Dynamic strings are expressions in disguise: the things >> in between $...$ are plain old expressions (with optional >> formatting specifications). They are evaluated >> as if they were ou

Re: Python Gotcha's?

2012-04-06 Thread mwilson
rusi wrote: > Are there languages (other than python) in which single and double > quotes are equivalent? Kernighan and Plauger's RATFOR (a pre-processor that added some C-like syntax to FORTRAN) did that. Published in their book _Software Tools_. Mel. -- http://mail.python.org/mail

Re: Python Gotcha's?

2012-04-06 Thread mwilson
Roy Smith wrote: > In article , mwil...@the-wire.com wrote: > >> rusi wrote: >> >> > Are there languages (other than python) in which single and double >> > quotes are equivalent? >> >> Kernighan and Plauger's RATFOR (a pre-processor that added some C-like >> syntax to FORTRAN) did that. Publi

Re: ordering with duck typing in 3.1

2012-04-07 Thread mwilson
Thomas Rachel wrote: > Am 07.04.2012 14:23 schrieb andrew cooke: > >> class IntVar(object): >> >> def __init__(self, value=None): >> if value is not None: value = int(value) >> self.value = value >> >> def setter(self): >> def wrapper(stream_in, thunk): >>

Re: Donald E. Knuth in Python, cont'd

2012-04-11 Thread mwilson
Antti J Ylikoski wrote: > > I wrote about a straightforward way to program D. E. Knuth in Python, > and received an excellent communcation about programming Deterministic > Finite Automata (Finite State Machines) in Python. [ ... ] > #You can adjust that for your needs. Sometimes I have the stat

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread mwilson
Adam Skutt wrote: [ ... ] > In the real world, if we were doing the math with pen and paper, we'd > stop as soon as we hit such an error. Equality is simply not defined > for the operations that can produce NaN, because we don't know to > perform those computations. So no, it doesn't conceptually

Re: confusing doc: mutable and hashable

2012-04-28 Thread mwilson
laymanzh...@gmail.com wrote: > I'm just learning Python. The python doc about mutable and hashable is > confusing to me. > > In my understanding, there is no directly relation between mutable and > hashable in Python. Any class with __hash__ function is "hashable". > > According the wiki: http:/

Re: syntax for code blocks

2012-04-30 Thread mwilson
Ben Finney wrote: > [ ... ] Even worse is the > penchant for ‘foo .bar()’, the space obscures the fact that this is > attribute access. I like the style sometimes when it helps to break the significantly different parts out of boilerplate: libbnem. BN_add .argtypes = [ctypes.POINTER (Bignu

ctypes details was: Re: syntax for code blocks

2012-04-30 Thread mwilson
> On 4/30/2012 17:02, Kiuhnm wrote: >> BignumTypePtr = ctypes.POINTER(BignumType) >> >> for op, op_word in ((libbnem.BN_add, libbnem.BN_add_word), >> (libbnem.BN_sub, libbnem.BN_sub_word)): >> op.argtypes = [BignumTypePtr] * 3 >> op_word.argtypes = [BignumTypePtr, ctypes.c_ulong] >> op.restype = op

Re: ctypes details was: Re: syntax for code blocks

2012-04-30 Thread mwilson
Kiuhnm wrote: > Regarding ctypes, try this to convince yourself that there's no problem > in reusing BignumPtrType: > from ctypes import POINTER, c_int > assert POINTER(c_int) is POINTER(c_int) print ('POINTERs are shareable:', ctypes.POINTER (BignumType) is ctypes.POINTER (BignumType))