Syntax across languages

skip at pobox.com skip at pobox.com
Sun Oct 23 13:23:57 EDT 2005


    Alex> I've seen enough occurrences of "lambda x: x" in Python code with
    Alex> a generally functional style that I'd love to have
    Alex> operator.identity (and a few more trivial functions like that) for
    Alex> readability;-)

But, but, but [Skip gets momentarily apoplectic, then recovers...]
"operator.identity" is way more to type than "lambda x: x".  Plus you have
to remember to import the operator module. <0.5 wink>

Not to mention which (from "pydoc operator"):

    [The operator module] exports a set of functions implemented in C
    corresponding to the intrinsic operators of Python.

Last time I checked, Python didn't have an intrinsic "identity" operator.

For which reason, I'd be -1 on the idea of an identity function, certainly
in the operator module.

Skip



More information about the Python-list mailing list