Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > First python project : Tuner

Reply
Thread Tools

First python project : Tuner

 
 
Jérôme
Guest
Posts: n/a
 
      01-17-2012
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.

--
Jérôme
 
Reply With Quote
 
 
 
 
Rick Johnson
Guest
Posts: n/a
 
      01-17-2012
On Jan 17, 8:16*am, Jérôme <jer...@jolimont.fr> wrote:

> 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.
 
Reply With Quote
 
 
 
 
Jérôme
Guest
Posts: n/a
 
      01-17-2012
Tue, 17 Jan 2012 08:48:13 -0800 (PST)
Rick Johnson a écrit:

> On Jan 17, 8:16Â*am, Jérôme <jer...@jolimont.fr> wrote:
>
> > 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.


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.


?

--
Jérôme
 
Reply With Quote
 
Jérôme
Guest
Posts: n/a
 
      01-17-2012
Tue, 17 Jan 2012 12:28:11 -0500
Rodrick Brown a écrit:

> You would get more responses if you used one of those sites that displayed
> the code right in the browser.


Thanks for the tip.

I thought people would rather open it in their own editor. (And I tend to
avoid third-party hosting.)

Here's an html rendering :

http://devs.jolimont.fr/tuner/downlo...r_v2_0.py.html

This is done with gvim. Too bad it lacks line numbering.

--
Jérôme
 
Reply With Quote
 
gst
Guest
Posts: n/a
 
      01-17-2012
On 17 jan, 15:16, Jérôme <jer...@jolimont.fr> wrote:
> Hi all.
>


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.

 
Reply With Quote
 
Jérôme
Guest
Posts: n/a
 
      01-17-2012
Tue, 17 Jan 2012 10:16:02 -0800 (PST)
gst a écrit:

> 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:


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.

--
Jérôme
 
Reply With Quote
 
Rick Johnson
Guest
Posts: n/a
 
      01-17-2012
On Jan 17, 1:38*pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> Jérôme <jer...@jolimont.fr> writes:
> > Rick Johnson a écrit:
> > > Besides, not everyone in this community is a "card carrying"
> > > pacifist.

> > ?

> 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)."""

 
Reply With Quote
 
Chris Angelico
Guest
Posts: n/a
 
      01-17-2012
On Wed, Jan 18, 2012 at 7:38 AM, Rick Johnson
<> wrote:
> On Jan 17, 1:38*pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
>> 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.


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: First python project : Tuner Jérôme Python 3 01-26-2012 06:39 PM
First Python project - comments welcome! Paul Scott Python 4 04-08-2008 08:10 AM
Learning Python - First Project KDawg44 Python 10 04-24-2007 02:59 PM
hat is a differnece between a lcd monitor with a tv tuner and a lcdtv and can u get free cable with a tv tuner sdsd A+ Certification 0 10-17-2005 08:16 AM
help with my first project on first job, how to read a strange file, thanks a lot!!!!!!! matt Java 9 10-27-2004 03:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57