News for hackers. Stuff that matters.
Re:One-lined Python by sp332 on Wednesday August 21, 2019 @10:25AM (#20757473)
The demo at the top doesn't work because it's expecting python 3 but the demo code is python 2.
Re:One-lined Python by trymas on Thursday August 22, 2019 @05:50AM (#20766296)
Even if fixed to python 3, still throws an error:

> Your code could not be one-lined. name 'reduce' is not defined

Re:One-lined Python by np_tedious on Thursday August 22, 2019 @06:15AM (#20766434)
Python3 put it in functools, I think. Ah the need for an import would prevent one lining.

Never quite understood that decision

Re:One-lined Python by gvx on Thursday August 22, 2019 @06:29AM (#20766502)
Reduce isn't used much. Things that tend to use reduce in languages like Haskell tend to be built from other primitives in Python.

Instead of reduce, you could use https://docs.python.org/3/library/functions.html#__import__

    __import__('functools').reduce
Re:One-lined Python by jmmcd on Thursday August 22, 2019 @09:05AM (#20767560)
The article goes on to use `__import__()` to one-line imports.