Re: First python project : Tuner
Fri, 20 Jan 2012 12:13:30 +0200 Anssi Saari a écrit: Jérôme jer...@jolimont.fr writes: - I tried to clarify the dependencies of my program by adding PyGObject (python-gi). I believe PyGObject is the name, but python-gi being the name of the debian package (and possibly other distros' package, I didn't check), I assumed it would be more helpful. You might mention that Debian Stable (Squeeze) doesn't have a new enough PyGObject to run your code. There's no package python-gi and the version of python-gobject is 2.21.4+is.2.21.3-1. Thanks for telling me. I've got the feeling that my move to Gtk3 was a bit too early. Two reasons I decided to switch to pygobject : * The advice on pygtk.org : New users wishing to develop Python applications using GTK+ are recommended to use the GObject-Introspection features available in PyGObject. * The fact that glade, that I wanted to use as well, now (from version 3.10) only supports GTK3 (or so I understand). The documentation is not as prolific as for pyGTK, to say the least. https://live.gnome.org/PyGObject points to * A tutorial (work in progress) : http://readthedocs.org/docs/python-gtk-3-tutorial/en/latest/index.html * A partial doc I don't really use : http://people.gnome.org/~johnp/girdocsalpha/Gtk/ * A few examples : http://developer.gnome.org/gnome-devel-demos/stable/ And as far as I heard, porting such applications to windows is not easy either. I would think it twice if I had to start a new project. -- Jérôme -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
Jérôme jer...@jolimont.fr writes: - I tried to clarify the dependencies of my program by adding PyGObject (python-gi). I believe PyGObject is the name, but python-gi being the name of the debian package (and possibly other distros' package, I didn't check), I assumed it would be more helpful. You might mention that Debian Stable (Squeeze) doesn't have a new enough PyGObject to run your code. There's no package python-gi and the version of python-gobject is 2.21.4+is.2.21.3-1. -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
Tue, 17 Jan 2012 15:16:01 +0100 Jérôme a écrit: 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. Hi. Thank you for your useful advices. - I tried to clarify the dependencies of my program by adding PyGObject (python-gi). I believe PyGObject is the name, but python-gi being the name of the debian package (and possibly other distros' package, I didn't check), I assumed it would be more helpful. - Frequency is now displayed on the main window under each key (it was already displayed in the selector widget) - Pylint helped me improve a bit. Mostly conventions. And it still yields what I believe are false-positives. I didn't try to configure it not to. Thanks for telling me about Pylint. This tool is helpful. - I also corrected the is misuse as ==. - Most importantly, new 2.1 version comes with an absolutely pure french-free english-only screenshot, for your convenience. http://devs.jolimont.fr/tuner/ http://devs.jolimont.fr/tuner/downloads/tuner_v2_1.py.html -- Jérôme -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
On Jan 19, 4:44 am, Jérôme jer...@jolimont.fr wrote: - Most importantly, new 2.1 version comes with an absolutely pure french-free english-only screenshot, for your convenience. Thanks for this update. However, i need to stress that while the English language is fundamental to writing Python code, we are not advocating doing away with French (or any other language) either. As long as you have an English screenshot you have met the expectations of this community. Feel free to add as many screen-shots in as many languages as required to serve your base. -- http://mail.python.org/mailman/listinfo/python-list
First python project : Tuner
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
You would get more responses if you used one of those sites that displayed the code right in the browser. On Tue, Jan 17, 2012 at 12:26 PM, Jérôme jer...@jolimont.fr wrote: 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 -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
Jérôme jer...@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 -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
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). -- http://mail.python.org/mailman/listinfo/python-list
Re: First python project : Tuner
On Wed, Jan 18, 2012 at 7:38 AM, Rick Johnson rantingrickjohn...@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 -- http://mail.python.org/mailman/listinfo/python-list