[Pythonmac-SIG] algorithm wanted

Ramm, Henning Henning.Ramm at mediapro-gmbh.de
Wed Feb 2 09:44:26 CET 2005


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 list of booleans,
>         e.g. 'CM0K' to [True, True, False, True]
>     """
>     return [x != '0' for x in s]
>
>print bool2cm0k([True, False, False, True]) # --> C00K
>print cm0k2bool('CM0K') # --> [True, True, False, True]

Thank you all very much!
This is what I imagined! :-)


Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.


More information about the Pythonmac-SIG mailing list