14 Nov
2007
14 Nov
'07
10:29 a.m.
I'm not sure if this is a good idea or not, but - hey - this is python.ideas ;-) The following statements currently raise a SyntaxError: obj[] = something x = obj[] I propose to make these statements valid syntax. 'obj[]' should behave like 'obj[()]' does: Call __getitem__ or __setitem__ with an empty tuple. My use case is in a COM library (comtypes). Some COM properties require one or more arguments; this is not a problem since one could write obj.prop[1, 2, 3] Sometimes, however, arguments are optional. Unfortunately one has to write obj.prop[()] to pass an empty tuple to __getitem__ or __setitem__, which looks strange imo. Comments? Thomas