Syntax across languages

bonono at gmail.com bonono at gmail.com
Sun Oct 23 09:08:11 EDT 2005


just curious, how can this identity function be used ? In haskell,
because all functions are curried, I can sort of visualize/understand
how id is used. Not quite understand how it can be used in python.

beza1e1 wrote:
> >>> id("blub")
> -1210548288
>
> This is not identity in a mathematical view.
>
> def identity(x): return x
>
> It has is uses. I had some kind of parser and had a dict like this:
> {case: function, ...} It had to be a dict, because i wanted to
> dynamically add and remove cases. In some cases nothing had to be done.
> To represent this in the dict a identity function is needed. There
> surely are other ways, but identity was the most expressive in my eyes.
> 
> Nice read, by the way. Thanks for sharing ;)




More information about the Python-list mailing list