[Python-il] [pyweb-il:302] Python questions

Beni Cherniavsky cben at users.sf.net
Mon Jul 20 20:51:02 IDT 2009

On Mon, Jul 20, 2009 at 19:55, Udi h Bauman<dibaunaumh at gmail.com> wrote:
> I need help with some questionnaire (just if you can think of something from-the-top-of-your-head):
> I'm looking for a couple of really difficult questions on Python, such that
> "non-python-experts" have <10% chances of getting them right. Could be about
> advanced usages, or just some esoteric holes, that only someone who wondered
> in Python fields for enough years is likely to have fell into..
> Any ideas?
What happens when you do ``obj.attr``, accounting for:
__getattribute__, descriptor lookup, instance __dict__, class
__dict__s lookup, __getattr__.


This might be too cruel.  Simpler question: how would you implement a
class property?
If the answer is property on metaclass, ask how it can be done without
metaclass -
the person should know that descriptor __get__ catches class accesses too
(that's how <unbound method> works, but few people realize it.)
Don't haggle over exact __get__ signature, nobody remembers that.

Beni <cben at users.sf.net>

More information about the Python-il mailing list