News for hackers. Stuff that matters.
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.
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.
Re:Show HN: Python library for functional programming by bpicolo on Thursday December 14, 2017 @10:50AM (#15923178)
Identifiers can't start with a number, so this should still be unambiguous probably?
Re:Show HN: Python library for functional programming by FRex on Thursday December 14, 2017 @11:10AM (#15923357)
Sure, that's the only example of line starting with a dot (I think, I'm not super good at Python, just okay) so anything else that isn't a float should be fine.