GNOME Bugzilla – Bug 586181
gobject::propertyhelper::property has name collisions to the new python property methods
Last modified: 2012-03-15 12:18:37 UTC
recent python versions added the methods getter/setter/deleter to propperties to help composing them in the class namespaces this directly clashes with the gobject property, which uses getter/setter for the get/set functions, Other information: http://docs.python.org/library/functions.html#property
Don't import property from gobject into the global namespace; use gobject.property instead to avoid name clashes.
i didn't mean the name of the class but the names of its attributes, which class with utility methods of property
I don't get it. Can you provide an example please?
the problem target is the following idiom: class test(object): @property def foo(self): ... @foo.setter def foo(self, val): ... it works with python's property, but it cannot wok with gobject's property since gobject properties mask those attributes instead of following the convention of pythons builtin properties (fget/set/del for the functions, setter/getter/deleter for the decorator utilities)
Created attachment 209583 [details] [review] Renamed getter/setter instance attributes. Renamed getter/setter instance attributes and added getter/setter methods to the GObject.property class to match that of the python property class and allow for decoratored setter methods. In addition, __call__ was added to allow an instantiated decorator with args to also decorate a method. The following works with this patch: class C(GObject.GObject): _value = 0 @GObject.property(type=int, default=0) def propInt(self): return self._value @propInt.setter def propInt(self, value): self._value = value
Very nice, thank you! Committed.