[Pythonmac-SIG] algorithm wanted

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


eichin at metacarta.com 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 expressiveness goes.

But very interesting for someone like me who never learned to think "functional". ;-)

>The code you have isn't actually unclear, so consider *why* you want
>to make it compact.

I like to have elegant code (hoping it will be faster, too)
and I like to learn "how the pros do it".

>What I don't see is why you have ProcessColors as a class, but I'm
>assuming there's context for that

The real class has some more methods, and the two converters are only private.
But you're right - I use the class here merely for grouping everything
that belongs together; I'm not really used to OO at all - I used to code
in Perl and now try to learn Python and OO at once. ;-)

> these converter functions are
>just that, functions, though I could see having a color object that
>also called them as methods, the idea of using a method of a color
>object to convert another color word in a way that has nothing to do
>with the color object itself seems an odd use of the object.

I thought, my 'color info object' should 'know' how to present itself
to different interfaces.

Best regards,
-----------------------
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Abt. Systembetreuung


More information about the Pythonmac-SIG mailing list