First python project : Tuner

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Jan 17 14:59:17 EST 2012


Jérôme wrote:
> Hi all.
>
> Like others before me, I'd like to show you my first python attempt, in the
> hope in can get advices on how to improve my coding.
>
> I started learning python and pyGTK last november. I had had a short
> experience of GTK with C, but had given up as I lacked time and I found it
> more difficult than I expected. python makes things more easy. Yet, after
> starting with pyGTK, I switched to PyGObject, and lack of documentation made
> small things a bit hard sometimes...
>
> The project I chose as an exercise is some sort of guitar tuner. It can be
> found here :
> http://devs.jolimont.fr/tuner/
>
> The choice of the sound backends was already discussed on this list. Next
> step would be to switch to a python audio library and use threads instead of
> processes.
>
> I added flags to avoid race conditions, perhaps with a little bit of
> clumsyness. This makes the code more complicated than it deserved to be.
>
> Any comment is welcome, be it about code optimization, coding style,
> pythonification, good practices, or simply program features and usability.
>
> Thanks.
>
>   
My system failed to import gi.repository
But don't bother I won't install anything anyway.
If it is not listed in your dependencies, maybe you should add it.

You could also display the frequency of A2 (possibly 440Hz), would give 
a pro touch to the thing :D

As for python, why don't use use 'pylint' on it. It is one good way to 
know about your code. It's not about correcting any error reported, but 
by simply looking at the messages/warnings, and asking yourself "why 
that rule ?" you can improve your coding style and design, maybe for the 
next application.

JM





More information about the Python-list mailing list