syntax for code blocks

mwilson at the-wire.com mwilson at the-wire.com
Mon Apr 30 10:17:08 EDT 2012


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 (BignumType), ctypes.POINTER (BignumType), 
ctypes.POINTER (BignumType)]
    libbnem. BN_add .restype = ctypes.c_int
    libbnem. BN_add_word .argtypes = [ctypes.POINTER (BignumType), ctypes.c_ulong]
    libbnem. BN_add_word .restype = ctypes.c_int
    
    libbnem. BN_sub .argtypes = [ctypes.POINTER (BignumType), ctypes.POINTER (BignumType), 
ctypes.POINTER (BignumType)]
    libbnem. BN_sub .restype = ctypes.c_int
    libbnem. BN_sub_word .argtypes = [ctypes.POINTER (BignumType), ctypes.c_ulong]
    libbnem. BN_sub_word .restype = ctypes.c_int

(there were a lot more in the original program where those came from.)  Another take-away 
might be don't use boilerplate, but in the situation I didn't see a simple way to avoid it.

	Mel.



More information about the Python-list mailing list