First python project : Tuner

J

Jérôme

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.
 
R

Rick Johnson

Any comment is welcome, be it about code optimization, coding style,
pythonification, good practices, or simply program features and usability..

Step one would be to show a screen shot in both English AND French
language. Besides, not everyone in this community is a "card carrying"
pacifist.
 
J

Jérôme

Tue, 17 Jan 2012 08:48:13 -0800 (PST)
Rick Johnson a écrit:
Step one would be to show a screen shot in both English AND French
language.

The screenshot was a dissatisfying mix of english and french because until
I18n is done (next in TODO list) all the strings are in english, but the stock
buttons are localized as my system is in french. Yet the inconsistency.

I didn't know it was as easy as

LANGUAGE=EN ./tuner_v2_0.py

to re-localize a program. Now the screenshot is english only.

Anyway, I was trying to bring people's attention to the python program
itself :
http://devs.jolimont.fr/tuner/downloads/tuner_v2_0.py
Besides, not everyone in this community is a "card carrying"
pacifist.

?
 
G

gst


hi,

just my 2 cents:

you have quite lot of such test:
if self._index is 0:

I think it's better to compare with equality against 0 (or other
needed value) ; that is:

if self._index == 0:

otherwise your code looks very nice to me, though I just had a very
quick look ;)

regards,

GS.
 
J

Jérôme

Tue, 17 Jan 2012 10:16:02 -0800 (PST)
gst a écrit:
you have quite lot of such test:


I think it's better to compare with equality against 0 (or other
needed value) ; that is:

if self._index == 0:

Yes, I just saw that thanks to Alex Willmer's e-mail.

I used to have ==, until for some strange reason I figured is was more
pythonic, so I replaced all == I could with is. I shouldn't have.

I appended this issue on top of my TODO list.

Although I try to read as much documentation as I can to do things clean,
there is still a lot of trial and error and sometimes my criterion ends up
being "does it works or does it not", whithout comprehensive understanding.
otherwise your code looks very nice to me, though I just had a very
quick look ;)

Thank you for the feedback.
 
R

Rick Johnson

You have attracted the attention of a troll.

What is worse: A wolf, or a wolf in sheep's clothing?

There is no "trolling" in my reply. A nice quip, yes. Trolling, no.
The fact remains that English is very important to Python. In fact,
English is SO important that the great Guido van Rossum himself
mentioned English explicitly in PEP8. And as we know, English is NOT
his first language!

GvR said: """Python coders from non-English speaking countries: please
write your comments in English, unless you are 120% sure that the code
will never be read by people who don't speak your language."""

GvR said: """All identifiers in the Python standard library MUST use
ASCII-only identifiers, and SHOULD use English words wherever feasible
(in many cases, abbreviations and technical terms are used which
aren't English)."""
 
C

Chris Angelico

What is worse: A wolf, or a wolf in sheep's clothing?

There is no "trolling" in my reply. A nice quip, yes. Trolling, no.

Well, as we learn from Innistrad, worse is a wolf in shepherd's
clothing. (Look up 'Gatstaf Shepherd'.)

Ben didn't say there was "trolling" in your reply. He said that the OP
had attracted the attention of a troll. That said, though, I would
have to say that your post was trollish.

ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top