Re: [pygccxml-development] Patch to add a little syntactic sugar
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2006-05-17 17:23:17
|
On 5/17/06, Allen Bierbaum <al...@vr...> wrote:
> I have included a patch that I find useful for simplifying decl lookup
> in pyplusplus.
>
> It allows code like the following to be written using the __getitem__
> interface.
>
> ns =3D mb.global_ns.namespace( 'my_ns',)
> ns["MyClass"].exclude()
> class_a =3D ns["ClassA"]
> class_a["doSomething"].include()
>
> It also allows an attribute interface (similar to Pyste).
>
> ns.MyClass.exclude()
> class_a =3D ns.ClassA
> class_a.doSomething.include()
>
> These both can be used to dramatically reduce the amount of clutter
> (redundant code calls) using in a script to generate bindings. Although
> the second one could be seen as a little dangerous because of potential
> name conflicts, I think the interface of Pyste has proven that people
> like an interface like this because it allows something that feels like
> a very tight domain specific langauge for creating bindings.
>
> I know that neither of these methods is anything more then syntactic
> sugar, but IMHO it is pretty sweet sugar. :)
Thanks. I will apply the patch. There is only one question:
Why not to implement the __getattr__ next way:
found_decls =3D self.decls(name=3Dname, allow_empty=3DTrue)
if found_decls:
return found_decls
else:
raise AttributeError
Why do you need treatment for '__' ?
> -Allen
Thanks.
--=20
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|