Re:Show HN: Python library for functional programming
by FRex on Thursday December 14, 2017 @09:28AM
(#15922429)
You can omit the leading 0 before the dot when writing float literals so just a '.1' or any other such sub-1 float literal with no leading 0 is technically a valid but useless line of code starting with a dot (you could use it instead of pass I guess..). I can't think of a real use of a line starting with a dot off the top of my head.
[ Parent
| on HN ]
Re:Show HN: Python library for functional programming
by owl57 on Thursday December 14, 2017 @02:48PM
(#15926198)
Probably nothing remotely resembling this belongs in anything remotely resembling production code, but:
In [1]: class Foo:
...: def __rmul__(self, other):
...: print("%s foos!" % other)
...:
In [2]: .42 * Foo()
0.42 foos!
Re:Show HN: Python library for functional programming
by FRex on Thursday December 14, 2017 @05:08PM
(#15927632)
That's very nice. I tried to go for such an example originally but I only tried __mul__ because I thought it's like in Lua where __mul gets used even if only the second operand has a custom one.