On Mon, Jul 20, 2009 at 19:55, Udi h Bauman<[email protected]> 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__.
http://cben-hacks.sourceforge.net/python/lectures/metaclasses/metaclasses.html 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 <[email protected]> _______________________________________________ Python-il mailing list [email protected] http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il
