Philipp,<div><br></div><div>Thanks so much for your time and comment. I will re-work my code accordingly.</div><div><br></div><div>Regards,</div><div>Emeka<br><br><div class="gmail_quote">On Sat, Sep 17, 2011 at 12:19 PM, Philipp Hagemeister <span dir="ltr"><<a href="mailto:phihag@phihag.de">phihag@phihag.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Instead of comments, you can often use docstrings<br>
(<a href="http://www.python.org/dev/peps/pep-0257/" target="_blank">http://www.python.org/dev/peps/pep-0257/</a> ):<br>
<br>
This is hard to read due to the indentation, and cannot be accessed<br>
programmatically:<br>
<br>
#Update the GUI<br>
def update_gui(self, new_word):<br>
<br>
Instead, use this:<br>
<br>
def update_gui(self, new_word):<br>
"Update the GUI."<br>
<br>
Now, you can use help(Message) to get information about the method.<br>
You'll notice "Update the GUI." is not helpfull at all for a method<br>
called update_gui. Comments (and docstrings) that reproduce the method<br>
name are not useful.<br>
<br>
A couple of minor things:<br>
<br>
* If you delete code, delete it, don't comment it out.<br>
* Use newlines between two methods. Compare<br>
def a(self):<br>
pass<br>
def b(self):<br>
pass<br>
def c(self):<br>
pass<br>
<br>
with<br>
<br>
def a(self):<br>
pass<br>
<br>
def b(self):<br>
pass<br>
<br>
def c(self):<br>
pass<br>
<br>
The latter looks neat and not nearly as crammed as the former.<br>
* Don't use newlines where they shouldn't be, for example in<br>
if val == 0:<br>
<br>
label.unbind('<Button-1>')<br>
* Even if it's just the comments, typos make a very bad impression of a<br>
coder and the code. I'd automatically assume lots of bugs and untested<br>
code when I see more than the occasional typo.<br>
* GUI programming is fun, but does not lend itself to structured<br>
programming and good practices. You should never use global. Instead,<br>
have an object encapsulating the state and pass that object to the<br>
method itself or its object.<br>
* Don't commit .pyc files, they're totally useless. Since python 2.6,<br>
you can add the following in your .bashrc to make python not create them:<br>
<br>
export "PYTHONDONTWRITEBYTECODE=dont"<br>
<br>
In git, you can add the following in your project's .gitignore or<br>
~/.gitignore_global:<br>
<br>
*.pyc<br>
<br>
[More on .gitignore: <a href="http://help.github.com/ignore-files/" target="_blank">http://help.github.com/ignore-files/</a> ]<br>
* Otherwise, the code looks pretty good for a beginner. You may,<br>
however, want to replace<br>
<br>
def word_not_found(word):<br>
if word in searchedwordset:<br>
return 0<br>
else:<br>
return 1<br>
<br>
with just:<br>
<br>
def word_not_found(word):<br>
return word not in searchedwordset<br>
<br>
(or just skip this method and write word not in searchedwordset).<br>
<br>
Cheers,<br>
<font color="#888888"><br>
Philipp<br>
</font><div><div></div><div class="h5"><br>
<br>
<br>
Emeka wrote:<br>
> Hello All,<br>
><br>
> While learning Python I put together another Text Twist. I would want<br>
> somebody to go through it and comment.<br>
> <a href="https://github.com/janus/Text-Twist" target="_blank">https://github.com/janus/Text-Twist</a><br>
><br>
><br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><i>Satajanus Nig. Ltd<br><br><br></i><br>
</div>