I have this dictionary
BRANDS = {
"Toyota": { "shortname": lambda s: s[:2] },
"Toyota Asia": { "shortname": lambda s: 'TyA' }
}
When cycling over the brands, I use the supplied lambda to get me a shortname for the brand. However, I would like to do some more complex things in that lambda
. Is there a way in Python 3 to provide an anoymous function (like we can do in C# or Javascript)? I know I can create a named function using def
, but I want all definition in the dictionary for administrative readons.
Whenever I search for anonymous functions online, I only get the lambda expressions.