Cleaned IRC log of #python starting Monday, 25 July, 2011 at 17:13:55 EDT.
Gems are highlighted in bold.
|GothAlice||How do I determine if a given object is a @classmethod, and, additionally, how do I determine if it is a @staticmethod? 1|
|KirkMcDonald||GothAlice: Why would you care?|
|GothAlice||KirkMcDonald: Enforcing interfaces, not that it matters.|
|dash||GothAlice: you’re right, it doesn’t matter|
|_habnabit||GothAlice, if you wanted an answer to the question as asked, why don’t you try ##python-friendly? #python is about writing better code.|
|nedbat||GothAlice: what KirkMcDonald should have said was, “The Python culture is to not check ahead of time, do you have an unusual requirement that means you really have to know?”|
|GothAlice||_habnabit: Cute, thank you for living up to expectations.|
|nedbat||_habnabit: you don’t have to treat people that way.|
|GothAlice||nedbat: Assume yes, I do have a requirement that needs this.|
|message144||heh today i learned that ##python-friendly is a real thing|
|GothAlice||nedbat: No worries, I expect that kind of behaviour from him and a few select others.|
|nedbat||GothAlice: the inspect module has lots of tools, not sure if it covers what you’re looking for.|
|GothAlice||nedbat: I’ve already looked, it doesn’t.|
|GothAlice||Also, _habnabit, it’s against channel rules to advertise other channels; or it was, last time I checked.|
|KirkMcDonald||GothAlice: The answer is obvious if you know how classmethod and staticmethod work. 2|
|nedbat||KirkMcDonald: that’s not that helpful an answer either.|
|GothAlice||KirkMcDonald: Again, thank you for meeting expectations. Is it any wonder I created ##python-friendly?|
|KirkMcDonald||GothAlice: Just yank the objects out of the thing and see what they are. 2|
|GothAlice||KirkMcDonald: Still not helpful. You do realize you’re wasting not just my time, but yours as well?|
|dash||GothAlice: You already know what to expect when you come here.|
|nedbat||dash: why is it ok for her to expect curt rude unhelpful answers?|
|dash||GothAlice: So please don’t expect us to be moved by your complaints about it.|
|Yhg1s||nedbat: there’s quite a bit of history involved.|
|dash||nedbat: A long history of disagreement.|
|nedbat||Yhg1s: I’m getting that sense, but in my experience, GothAlice is not unusual in this regard. Lots of people have come to expect those answers.|
|KirkMcDonald||nedbat: We’re not here to just answer asked questions.|
|Yhg1s||nedbat: if the questions are about bad ideas, then yes, many people won’t give direct answers. With good reason. All too often, if they are given something that does what they seem to want, it’ll just ruin their design and they’ll come back crying later.|
|Yhg1s||nedbat: #python is about helping people write Python, not get something working.|
|nedbat||i’ve heard all this before. Some people disagree. I won’t take more of your time.|
|GothAlice||I think that’s the primary conflict, here. I feel no need to justify myself when asking a question about a real problem I’m encountering. I’ve been programming commercially since I was 9, and generally my OSS code speaks for itself. I’m not an idiot, don’t treat me as one.|
|Yhg1s||nedbat: this is why there’s other channels :)|
|Yhg1s||GothAlice: And yet you insist on treating us as idiots. Thanks. 3|
|GothAlice||However, my particular use case involves writing an interface declaration and enforcement system, similar to zope.interface, but a fair bit simpler.|
|KirkMcDonald||GothAlice: If you find that you actually need to do this sort of metaprogramming nonsense, I am surprised you don’t know how to do it. 4|
|nedbat||KirkMcDonald: we’ve established that you are surprised. Now, do you know the answer?|
|KirkMcDonald||That you have sufficient skill for this kind of metaprogramming to be a need but insufficient skill to just do it is strange to me. 4|
|dash||GothAlice: I would note that not even zope.interface checks if things are staticmethods or classmethods. :)|
|KirkMcDonald||I gave the answer: Get the objects. See what they are instances of. 2|
|dash||GothAlice: So your approach already sounds less simple|
|nedbat||KirkMcDonald: when i get a classmethod from an object, its type is “instancemethod”.|
|NelleV||GothAlice: maybe you’ll have more answers on the python-list mailing list|
|Yhg1s||nedbat: you have to get it from the class, of course.|
|KirkMcDonald||To get the actual classmethod object, you don’t even get it from the class. You need to sidestep the descriptor protocol.|
|Yhg1s||some knowledge of how these things work is necessary, if you want to do these kinds of things. There’s several decent documents on the interwebs that explain how classes, metaclasses and descriptors like staticmethod and classmethod work. [17:29:43]|
|GothAlice||Yhg1s: A ha, descriptor protocol. Thank you for finally being useful. type(obj).mro() + dict here I come. 5|
|Yhg1s||GothAlice: ‘finally being useful’. Thanks again.|
|Yhg1s||GothAlice: your hostile attitude is as old as your passive-agressiveness. Please go away, learn to act like a civil person or ask better questions (preferably all three.) 6|
|GothAlice||Yhg1s: Just giving credit where credit is due. Those two words took 15 minutes and solved my problem. Additionally, the question was perfectly sound. Your insistence on correcting the purpose of others’ code is the problem.|
|Kaedenn||GothAlice: Welcome to #python|
|Kaedenn||GothAlice: I see you’re new here|
|17:33:40||mode (+o Yhg1s) by ChanServ|
|17:33:51||mode (+b !firstname.lastname@example.org.*) by Yhg1s|
|17:33:52||You have been kicked by Yhg1s: (Don’t come back.)|
1 If you can argue that this isn’t a clear and concise question, please comment.
2 Snide and/or unhelpful answers that are such in any context. Pretend you’re a tourist, and from everyone you ask “How do I get to X?” you get “Well, if you lived here, you’d know!”
3 Not sure how dismissing useless answers is treating someone as an idiot… sure, repeatedly pointing out someone is living up to low expectations (held not just by me) might be insulting, but when it’s demonstrated again and again—within the same conversation no less—it’s not unjustified.
4 These aren’t even subtle.
5 Should have been directed at KirkMcDonald and Yhg1s.
6 Prior to the actual answer there was one attempted good-faith answer (inspect module, alas, not viable), two dismissals, three purposefully vague and unhelpful answers, at least two thinly veiled insults, and three suggestions to ask elsewhere (though one was more along the lines of “You know we won’t help you, so why do you bother?”).
This is not a good sign for what one might usually refer to as a “Python support community”. Operative word being support. Thank you, nedbat, for helping. The inspect module, after further inspection, does contain code that can be helpful by way of the undocumented
classify_class_attrs function, which works in much the same way as my own code.
For future reference, the solution is attached.