News for hackers. Stuff that matters.
Re:Python Design Patterns (2018) by chapium on Sunday March 13, 2022 @03:21PM (#30664785)
I feel a bit contrarian about design pattern lists. These always seem to contain a list of solutions and after some fancy gymnastics, a list of potential problems they might solve. I feel it might be more useful to create a list of common software problems and follow them with a pattern that helps solve the problem. I think this would help address the issue of these pattern guides being applied overzealously.
Re:Python Design Patterns (2018) by amardeep on Monday March 14, 2022 @12:55AM (#30668648)
Reading top comments might make someone feel that this article is not worth reading, but I encourage people to actually read it. Personally I find it really interesting.

For eg. reading about prebound methods here: https://python-patterns.guide/python/prebound-methods/. Seasoned python programmers probably wouldn't find anything interesting there, but for me, it was quite useful including instances of where it is being done in python standard library and discussion around when and when shouldn't it be used.

Re:Python Design Patterns (2018) by e19293001 on Monday March 14, 2022 @01:18AM (#30668761)
I agree. The information is interesting to read and it is well written.
Re:Python Design Patterns (2018) by Spivak on Monday March 14, 2022 @01:52PM (#30675607)
Bound methods in Python are one of the keys to enlightenment to understanding its object system -- that self isn't magic and you could implement it yourself (for example having instance methods take a self, and cls parameter) if you wanted. One fun exercise is implementing an object that can "adopt" loose functions.

   def some_random_function(self)
     print(self.internal_state)

   ...

   mymagicobject.func = some_random_func

   mymagicobject.func()  # -> prints the internal state of the object
Re:Python Design Patterns (2018) by bmn__ on Monday March 14, 2022 @03:41AM (#30669489)
> a list of common software problems and follow them with a pattern that helps solve the problem

Better yet, improve the programming language, so that any user may benefit, not just those who know about the obscure list.

https://blog.plover.com/prog/design-patterns.html

Re:Python Design Patterns (2018) by syntaxfree on Sunday March 13, 2022 @06:34PM (#30666400)
Pattern clusters would be better. Like “… so you want to design a programming language, this is the Visitor pattern, the Dispatch…”
Re:Python Design Patterns (2018) by xtiansimon on Sunday March 13, 2022 @06:18PM (#30666304)
Cookbook?