[issue15289] Adding __getitem__ as a class method doesn't work as expected

2012-07-10 Thread samwyse
samwyse added the comment: Thanks, Eric. Based on what you said, I was able to get the desired behavior by creating a metaclass. -- Added file: http://bugs.python.org/file26343/Issue15289.py ___ Python tracker _

[issue15289] Adding __getitem__ as a class method doesn't work as expected

2012-07-07 Thread Eric Snow
Changes by Eric Snow : -- components: +Interpreter Core -None resolution: -> invalid stage: -> committed/rejected status: open -> closed ___ Python tracker ___

[issue15289] Adding __getitem__ as a class method doesn't work as expected

2012-07-07 Thread Eric Snow
Eric Snow added the comment: This appears to be a misunderstanding about special-method lookup which, honestly, isn't super obvious at first. It helps to remember that classes are objects like everything else in Python and thus are instances of some type (their metaclass). Anyway, here's th

[issue15289] Adding __getitem__ as a class method doesn't work as expected

2012-07-07 Thread samwyse
New submission from samwyse : I'm using a class as a decorator, and saving information in a class variable. I wanted to access the information via a __getitem__ class method, but using conventional syntax doesn't work on a class. The following exception is thrown when the attached script is