Advice Criticism on Python App

Chris Rebert clp2 at rebertia.com
Tue Mar 23 21:32:11 EDT 2010


On Tue, Mar 23, 2010 at 5:05 PM, Jimbo <nilly16 at yahoo.com> wrote:
> I have made a Python App(really script) that will check a stocks
> current values from a website & save that data to a SQLite 3 database.
>
> I am looking for any suggestions & criticisms on what I should do
> better or anything at all but mainly in these areas:
<snip>
> Any advice criticism would be really helpful.

Complying with Python naming conventions would be one place to start:
* Class names should be in StudlyCaps (so class "Stock", not class "stock").
* Constants should be in UPPERCASE_WITH_UNDERSCORES.
* Most other names should be words_separated_by_underscores, not
camelCaseLikeThis; FWIW, I'm not a fan of this part of the guideline
personally.

Also, conditions don't need parentheses around them. So:
if (decision == 1): #WRONG! harder to read, extra syntactic noise
if decision == 1: #RIGHT

For many more style details, see PEP 8 -- Style Guide for Python Code:
http://www.python.org/dev/peps/pep-0008/

Additionally, the "return 0" in main() serves no purpose; the return
value isn't used as the exit code for the program. You can either
eliminate the line entirely or use plain "return" if you want the
extra clarity.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list