Why can't you use call syntax, i.e. obj.prop(1, 2, 3)? On Nov 14, 2007 10:29 AM, Thomas Heller <theller@ctypes.org> wrote:
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
_______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas
-- --Guido van Rossum (home page: http://www.python.org/~guido/)