RE: [Pythonmac-SIG] algorithm wanted

2005-02-02 Thread Ramm, Henning
has and Dethe wrote: >def bool2cm0k(lst): > """Converts a list of booleans to a CMYK color string, > e.g. [True, False, False, True] to 'C00K' > """ > return ''.join([b and c or '0' for b, c in zip(lst, 'CMYK')]) > >def cm0k2bool(s): > """Converts a CMYK color string to a l

RE: [Pythonmac-SIG] algorithm wanted

2005-02-02 Thread Ramm, Henning
[EMAIL PROTECTED] wrote: "".join(map(lambda x,y: {True:x, False:"0"}[y], _cmykMap, >[True, False, True, True])) >'C0YK' >but I'd break that down into a selector function (rather than a >lambda) or something to make it readable, since it's way too far on >the lisp side of things as far as exp

Re: [Pythonmac-SIG] algorithm wanted

2005-02-01 Thread Dethe Elza
On 1-Feb-05, at 4:47 PM, has wrote: Henning Hraban Ramm wrote: I'm looking for a better algorithm... This is probably as terse as it gets: [snip] # zip() isn't needed in this direction def cm0k2bool(s): return [x != '0' for x in s] --Dethe "The law I sign today directs new funds and new focus t

Re: [Pythonmac-SIG] algorithm wanted

2005-02-01 Thread has
Henning Hraban Ramm wrote: I'm looking for a better algorithm... This is probably as terse as it gets: def bool2cm0k(lst): """Converts a list of booleans to a CMYK color string, e.g. [True, False, False, True] to 'C00K' """ return ''.join([b and c or '0' for b, c in zip(lst, 'CM

Re: [Pythonmac-SIG] algorithm wanted

2005-02-01 Thread eichin
It's certainly one of the things map+lambda are for >>> "".join(map(lambda x,y: {True:x, False:"0"}[y], _cmykMap, [True, False, >>> True, True])) 'C0YK' but I'd break that down into a selector function (rather than a lambda) or something to make it readable, since it's way too far on the lisp si

[Pythonmac-SIG] algorithm wanted

2005-02-01 Thread Ramm, Henning
Hi there! I'm looking for a better algorithm... In a print project I must know if some page needs every CMYK separation or just some; I keep this info in a boolean list like [True, True, False, True] for C,M,K (no Y plate). But our workflow database needs a string like "CM0K" (plate letter or z