4 ms·
Yea I have no idea why this is on the homepage. It's so mundane.
by hasenj 12y ago
Yea I have no idea why this is on the homepage. It's so mundane.
- eatonphil 12y agoReplicating class functionality using only closures is mundane? At the very least it's cute. I didn't realize all beginning Python programmers knew what they could do with closures. My point is, why have a class syntax at all? It's such a mess, "self" isn't even implicit. You don't even need to declare class methods inside the class. You just have to make sure you pass self to the class method. This seems very loosely wrapped around what I did. Except class syntax is native. Why? I just really don't care for how sloppy the python class syntax is. /rant
- AnkhMorporkian 12y agoSelf isn't implicit by design. One of the core python philosophies is that explicit is better than implicit.
- eatonphil 12y agoThen isn't this pattern the epitome of the philosophy? At some point you trade an api for being explicit. Why isn't memory management explicit in python? I just don't agree with the (seemingly arbitrary) choice of making self explicit. It really does not feel like the "Python" way.
- AnkhMorporkian 12y agoHere's a link from Guido's blog back in '08 why he explains why he rejected a proposal on removing explicit self from the language. I feel he's more qualified to argue this than I. http://neopythonic.blogspot.com/2008/10/why-explicit-self-has-to-stay.html http://neopythonic.blogspot.com/2008/10/why-explicit-self-ha...
- hasenj 12y agoIt's mundane because there's nothing special about it. Everyone knows python has dictionaries. Everyone knows python has functional features. Everyone knows you can attach functions as properties of objects. There's really nothing new or interesting about it. Except maybe for beginners. Which is fine. Nothing wrong with being a beginner. It's just not what I expect to see on the frontpage of HackerNews. That's almost like someone saying: look wow, 2+2 and 2*2 and 2^2 all return the same result! Sure, amusing when you realize it for the first time, but hardly interesting for anyone but a first grader.
- eatonphil 12y agoWhen have you seen this pattern shown in a Python beginners tutorial? ... or anywhere? I have never seen this pattern before and for that reason it is interesting.
- hasenj 12y agoWhy would it show in beginner tutorials? It's just not pythonic. > There should be one-- and preferably only one --obvious way to do it. Not to mention that the object['field'] syntax is rather annoying.