24

I just found this grandiose function in our code

```
def t(s):
return s
```

Comments
  • 2
    Easier to change function return unchanged input value than to remove its use from all code.
  • 1
    I did something similar yesterday but with a lambda. I needed to add an optional post processing function as an argument to another function but I hate None defaults as they add that ugly "if x is None" boilerplate, so my default post processing function was an identity function "lambda x: x". That should be built-in IMO.
  • 4
    Identity function is actually more useful than it looks like
  • 1
    It's something that we can't understand fellas. Something big. Something out of this world.

    Enough with the joke. WTF?
  • 1
    I correct: This function is called exactly once.
  • 0
    @turbopixel It may be useful as a default but it's still strange nonetheless.
  • 2
    @Khepu I think all languages with first class functions have a built in identity function
  • 0
    Usefull in very specific cases, where methods are overridden, or bound to intances in runtime.
    Also usefull for monkey patching runtimes.
Add Comment