Re: [pygccxml-development] Properties vs methods
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-03-31 18:24:46
|
On 3/31/06, Matthias Baas <ba...@ir...> wrote: > Hi, Good evening. > I just noticed a disadvantage of using attributes (properties) instead > of method calls for things like decorating declarations. The problem is > that things like typos in the source code do not get noticed because > this will just attach a new attribute to the declaration instead of > producing an error. A line like > > m.callpolicies =3D return_self() > > looks as if it would assign a policy to a method m, but it doesn't > because the attribute is misspelled. This error is quite hard to find. > A method call on the other hand results in an attribute lookup which > raises an exception when the attribute doesn't exist (or when it's not > callable). I am aware of this problem. I developed few techiques that help me to solve= that problem quickly: 1. Set breakpoint on set property method. If you don't hit it - you misspelled the name 2. Try to use PyChecker or something like this. It could help. 3. I think, we still can use properties, but we will make thier get/set functions to be public: class xxx: def set_x(...) def get_x(...) x =3D property( set_x, get_x ) So if you want you can use functions instead of properties. If you like 3'rd idea, we can implement the idea after this release. > - Matthias - -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |