4 ms·
(I'm the author of this module.) Yeah, I admit part of me felt dirty implementing this by commandeering operators. But my brief time with Haskell and F# has b
by Niten 15y ago
(I'm the author of this module.)
Yeah, I admit part of me felt dirty implementing this by commandeering operators. But my brief time with Haskell and F# has biased me enough toward this style of function composition that I preferred to deal with the ugliness of my hack, rather than the ugliness of not being able to express certain functions in this style in my other toy projects. :)
I agree though, hopefully the language itself will support this one day, and then my ugly hack can go away. (I swear, Python always seems to stop just shy of being a fantastic little dynamic fp language...)
Thanks for the feedback!
- nakkiel 15y agoI'd really love to see an operator for this in Python as well. I feel it's lacking.
- mattdeboard 15y agoTrust me I am right there with you; Haskell does a lot of really beautiful things. Python lifted its list comprehension syntax from Haskell, as a matter of fact. It is only that I consider it a core responsibility of programmers to take into consideration the poor sap who has to maintain their code once the original author gets hit by a truck or eaten by a shark.
- MostAwesomeDude 15y agoPython's an object-based, highly dynamic, systems language. It's got a big set of builtins, a relatively large standard library, and is based around iteration and composition. It's not what I would consider a "little" or "fp" language. Sure, you can write pure, referentially-transparent units in Python, but sometimes you have to write things that set! attributes, and that's just a part of life. Overloading these operators on function objects really isn't the end of the world. It's not like these operators were being used for anything, and sometimes this kind of DSL-ish extension can be good. It's certainly more reasonable than the goto module, which uses horrid bytecode hax to get the job done. If you want this in the language, write to the python-ideas mailing list, and then draft a PEP if you get any support. Good luck!
- sinope 15y agoPython is most certainly not a systems language and if you think a PEP for this would go anywhere, you clearly don't know the devs very well either. Guido would never, ever allow anything like this into Python. Not when he's been campaigning to get rid of itertools.
- neilk 15y ago> hopefully the language itself will support this one day, and then my ugly hack can go away. +1 here, but I'm not holding my breath. Python's BFDL has been hostile to making lambda more powerful; I'm not sure what he would think about this. I think the syntax is fine. The star operator already is sensitive to the operands, so you're not impairing readability at all.