News for hackers. Stuff that matters.
Re:Toolz: A functional standard library for Python by dragonwriter on Thursday January 21, 2021 @06:11PM (#25865911)
Functional programming in Python is severely hampered by the fact that Python is statement-oriented rather than expression-oriented.

The lambda limitations are a product of this plus the particular whitespace rules Python has.

Re:Toolz: A functional standard library for Python by patrec on Thursday January 21, 2021 @07:12PM (#25866550)
This has really not been true since python grew a ternary operator, syntactically you can write functional code perfectly fine in python -- the only significant syntactic shortcoming is lack of pattern matching.

What actually hampers functional expression is semantics and mostly two-fold:

1. functions are terribly slow and always grow stack, so cannot replace iterative constructs.

2. Although python actually comes with a fair amount of functional data structures out of the box (str, bytes, tuple, frozenset, namedtuple, ...) none of them can be "updated" efficiently.

There are some other things (exception as opposed to sum-type based error handling), but fixing the above would be enough to write functional code pretty unhampered, I think.

Re:Toolz: A functional standard library for Python by heavyset_go on Friday January 22, 2021 @10:57PM (#25879492)
Pattern matching is on the roadmap for Python 3.10[1].

[1] https://www.python.org/dev/peps/pep-0622/

Re:Toolz: A functional standard library for Python by dragonwriter on Thursday January 21, 2021 @07:33PM (#25866719)
> Although python actually comes with a fair amount of functional data structures out of the box (str, bytes, tuple, frozenset, namedtuple, …) none of them can be “updated” efficiently.

If they can’t be updated efficiently, they are just immutable than particularly functional.

Re:Toolz: A functional standard library for Python by patrec on Friday January 22, 2021 @03:58AM (#25869777)
Of course I agree that calling such data structures immutable is more precise, but it's still in contrast to both imperative programming and imperative data structures. In particular every single functional language (including the purest of the pure) fairly heavily use immutable array based structures in one way or other. So if functional programming requires only using data structures with structural sharing, there are no functional programming languages.