Re:Python: Uncovering the Overlooked Core Functionalities
by JoshuaDavid on Monday July 24, 2023 @11:59PM
(#36857695)
Here you go:
This allows you to do stuff like
Deciding whether or not this is something you should do, rather than just something you can do, is left as an exercise for the reader.
[ Parent
| on HN ]
Re:Python: Uncovering the Overlooked Core Functionalities
by j-krieger on Tuesday July 25, 2023 @07:20AM
(#36860674)
This reads so much better
Re:Python: Uncovering the Overlooked Core Functionalities
by JoshuaDavid on Tuesday July 25, 2023 @12:26PM
(#36864844)
If you actually think this code is better there's a real library that does this: https://github.com/EntilZha/PyFunctional.
Re:Python: Uncovering the Overlooked Core Functionalities
by kzrdude on Tuesday July 25, 2023 @04:42PM
(#36869129)
One puzzling thing is that it uses backslash continuation in its examples. The most favoured style, IMO is to use ()'s for line continuation, maybe the author just doesn't know about those.
Re:Python: Uncovering the Overlooked Core Functionalities
by SpikyBlackHard on Tuesday July 25, 2023 @08:16AM
(#36861156)
Python debugging is most sane when the code just tries to keep it simple. After thousands of pdb sessions I can say most people should not be allowed to do this kind of thing in real code!
Re:Python: Uncovering the Overlooked Core Functionalities
by ijustlovemath on Tuesday July 25, 2023 @08:25AM
(#36861233)
You could improve the speed a little bit (maybe) by doing something like:
self._fns = {fn.__name__: fn for fn in [...]}
This may not be faster since the list is so short, but worth checking into
Re:Python: Uncovering the Overlooked Core Functionalities
by kzrdude on Tuesday July 25, 2023 @04:40PM
(#36869084)
With a small reminder that the pythonic way to do filter and map is even more readable - but it's limited in scope:
[x * 3 for x in [1, 2, 3, 4] if x % 2 == 0]
with that said, I still love the general concept of chaining, and I use that style a lot where it is already convenient and popular - in pandas code.
Re:Python: Uncovering the Overlooked Core Functionalities
by zelphirkalt on Wednesday July 26, 2023 @07:29AM
(#36875933)
And herein we see a weakness of Python: There is no way to get rid of the lambda lambda lambda, without actually naming things using def. Even though we are defining a pipeline of steps, still have to put up with syntactic clutter. Compare with threading/pipeline in other languages.