Learning by example
By einar
- CommentsWith my brand-new SVN account, I just committed some code to kdeexamples, KDE’s example code module. In particular, I committed a simple example which shows how to use KConfigXT via PyKDE4, a simplified version of [what I wrote about here]({{ site.url }}/2009/10/howto-kconfigxt-with-pykde4).
As most of KDE is C++, and the Python API docs are translated directly from the C++ API docs, it is essential to have good examples to help newcomers learn faster. There are some PyKDE4 examples in the kdebindings module already, but I put mine in kdeexamples for a number of reasons:
- Clear purpose: kdeexamples is meant exactly for this - example code;
- Visibility: A central place to find KDE examples even for bindings is optimal, makes easier to find what one is looking for.
Visibility is also important as currently the examples are rather buried inside kdebindings, and as far as I know they aren’t included in the packages of some distributions (at least not openSUSE; YMMV).
I decided to take this route because PyKDE4 is basically the job of one person (Simon Edwards): he does already a great job, but the work is too much for a single person to handle. And due to shortage of human resources, PyKDE4 lacks examples and documentation, and thus it’s not always easy to understand how to use the C++ API in Python. Writing snippets of working code, with extensive comments, is a step in the good direction. And also an opportunity to contribute back to KDE after all these years!
For now there’s just KConfigXT, but I plan on tackling KIO next, as soon as I have time. Of course, help is welcome!