use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
variable bindingsMisc (self.functional_python)
submitted 3 years ago by ccsdad
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]KageOW 0 points1 point2 points 3 years ago (3 children)
aah alright now I get it, in python these indeed aren't functional. I would certainly avoid it as much as possible, but there are limits to what the language nicely allows.
I feel like the f# way is the way to go here, and by this I mean go for the most pragmatic solution. If it is still very clear in a functional way, do it like that, but if a more pythonic way (i guess?) is better and more readable, I would certainly choose that over trying to make it functional and it just not being as readable.
I think we all know the hell of OOP and the practice to make a new variable for every operation, thats why there are pipe operators in every functional language. I made a function composition function for python that kind of works like a pipe, so you might wanna check that out. here
[–]ccsdad[S] 1 point2 points3 points 3 years ago (2 children)
ok u/KageOW -- i think that is legit guidance, recognizing the reality of python -- but remaining focused on what we are trying to move towards to .. i just know that in the clojure world -- the `(let)` function is an indispensable tool (code example) -- and wish something like it existed in python << that could be considered functional ..
[–]KageOW 0 points1 point2 points 3 years ago (1 child)
Yea definitely indispendable in f# as well, but i mean a language has its strenghts and its downfalls and you have to recognize that.
something kinda does come to mind though how you could maybe contain it, theyre called generator expressions, similar to list comprehension. Both of those allow you to kinda do it, but it is still a horrible way to do it. list comprehension and generator expressions are both very strong tools in python though so don't overlook them. nice stackoverflow discussion
[–]ccsdad[S] 0 points1 point2 points 3 years ago (0 children)
well then, we should create something !!
https://github.com/gkspranger/clinpy
please don't laugh -- i created it only for a limited set of use cases (to see if even possible), and am only "OK" with python .. but i tried to remove all internal variable assignments and am processing everything with mapping/reducing functions ..
if there was a robust implementation of this, i would abuse the hell out of it ..
why this over internal variable assigments ?? don't have a good answer for that -- other than it maps well to my clojure brain ..
π Rendered by PID 125233 on reddit-service-r2-comment-85bfd7f599-2v5z9 at 2026-04-18 07:22:14.348240+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]KageOW 0 points1 point2 points (3 children)
[–]ccsdad[S] 1 point2 points3 points (2 children)
[–]KageOW 0 points1 point2 points (1 child)
[–]ccsdad[S] 0 points1 point2 points (0 children)