Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19058 > unrolled thread

First python project : Tuner

Started byJérôme <jerome@jolimont.fr>
First post2012-01-17 15:16 +0100
Last post2012-01-17 20:00 +0100
Articles 9 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  First python project : Tuner Jérôme <jerome@jolimont.fr> - 2012-01-17 15:16 +0100
    Re: First python project : Tuner Rick Johnson <rantingrickjohnson@gmail.com> - 2012-01-17 08:48 -0800
      Re: First python project : Tuner Jérôme <jerome@jolimont.fr> - 2012-01-17 18:26 +0100
        Re: First python project : Tuner Ben Finney <ben+python@benfinney.id.au> - 2012-01-18 06:38 +1100
          Re: First python project : Tuner Rick Johnson <rantingrickjohnson@gmail.com> - 2012-01-17 12:38 -0800
            Re: First python project : Tuner Chris Angelico <rosuav@gmail.com> - 2012-01-18 07:46 +1100
      Re: First python project : Tuner Jérôme <jerome@jolimont.fr> - 2012-01-17 18:48 +0100
    Re: First python project : Tuner gst <g.starck@gmail.com> - 2012-01-17 10:16 -0800
      Re: First python project : Tuner Jérôme <jerome@jolimont.fr> - 2012-01-17 20:00 +0100

#19058 — First python project : Tuner

FromJérôme <jerome@jolimont.fr>
Date2012-01-17 15:16 +0100
SubjectFirst python project : Tuner
Message-ID<mailman.4813.1326810025.27778.python-list@python.org>
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

[toc] | [next] | [standalone]


#19059

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2012-01-17 08:48 -0800
Message-ID<296de6ba-2929-44de-bb26-8eea343b6875@h12g2000yqg.googlegroups.com>
In reply to#19058
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.

[toc] | [prev] | [next] | [standalone]


#19060

FromJérôme <jerome@jolimont.fr>
Date2012-01-17 18:26 +0100
Message-ID<mailman.4814.1326820995.27778.python-list@python.org>
In reply to#19059
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

[toc] | [prev] | [next] | [standalone]


#19067

FromBen Finney <ben+python@benfinney.id.au>
Date2012-01-18 06:38 +1100
Message-ID<87d3ai3yre.fsf@benfinney.id.au>
In reply to#19060
Jérôme <jerome@jolimont.fr> writes:

> Anyway, I was trying to bring people's attention to the python program
> itself

Welcome!

You have some replies now, that's good.

> Rick Johnson a écrit:
> > Besides, not everyone in this community is a "card carrying"
> > pacifist.
>
> ?

You have attracted the attention of a troll.

Please search for that person's past messages in the recent archives of
this forum, and then decide whether it's worth continuing a dialogue
with him.

-- 
 \            “Choose mnemonic identifiers. If you can't remember what |
  `\                mnemonic means, you've got a problem.” —Larry Wall |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#19069

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2012-01-17 12:38 -0800
Message-ID<9cc86927-e396-4430-88fc-eb7e11fe4eb5@u20g2000yqb.googlegroups.com>
In reply to#19067
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)."""

[toc] | [prev] | [next] | [standalone]


#19070

FromChris Angelico <rosuav@gmail.com>
Date2012-01-18 07:46 +1100
Message-ID<mailman.4820.1326833192.27778.python-list@python.org>
In reply to#19069
On Wed, Jan 18, 2012 at 7:38 AM, Rick Johnson
<rantingrickjohnson@gmail.com> 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

[toc] | [prev] | [next] | [standalone]


#19061

FromJérôme <jerome@jolimont.fr>
Date2012-01-17 18:48 +0100
Message-ID<mailman.4816.1326822315.27778.python-list@python.org>
In reply to#19059
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/downloads/tuner_v2_0.py.html

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

-- 
Jérôme

[toc] | [prev] | [next] | [standalone]


#19063

Fromgst <g.starck@gmail.com>
Date2012-01-17 10:16 -0800
Message-ID<d4c8392c-7d66-4581-b33d-1045a93e997e@a11g2000vbz.googlegroups.com>
In reply to#19058
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.

[toc] | [prev] | [next] | [standalone]


#19066

FromJérôme <jerome@jolimont.fr>
Date2012-01-17 20:00 +0100
Message-ID<mailman.4818.1326826663.27778.python-list@python.org>
In reply to#19063
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web