@vaporeon_ here's a really fun one because i can imagine it being genuinely useful in normal code but it's so fucking weird the way it's implemented
if you call type()
with one argument, you get the type of the argument back
if you call type()
with three arguments, the first of which is a string, the second is a collection (list, tuple, etc) of types, and the third is a mapping (dict, etc), it returns a class with the given name, inheriting from the given types, and with the given named values
one of these challenges wanted me to create a variable called Solution
set to an object with a main
method that printed "Hello World!"
Solution=type('',(),{'main':lambda*a:print('Hello World!')})()
@vaporeon_ @monorail I love python but lambda
is python's horrible anonymous function syntax and I hate it
@vaporeon_ @monorail the syntax is
lambda <arguments> : <return value>
. The splat syntax is python's way of expressing variadac arguments--however many argument are provided to the function will be stored as a list in the name to the right of the splat.