Off-Topic Discussion > Programming

My pet python project

(1/1)

pecenipicek:
I've released my project for fan control on linux on  github


I'd appreciate it if someone well versed in python and or OOP could guide me to a better codebase :)

Spicious:
First off, go read http://legacy.python.org/dev/peps/pep-0008/ and http://google-styleguide.googlecode.com/svn/trunk/pyguide.html and follow them.
Use the provided logging library instead of rolling your own; it's good: https://docs.python.org/3/howto/logging.html.
Don't discard exceptions; an object failing to construct really should inform the caller.
Use tuples instead of lists for fixed sized things.
Use list and dict literals ([] and {}) instead of list() and dict().
Don't use __del__ if at all possible.

Kopachris:
I was going to mention some of the stuff Spicious mentioned, but then I realized I'm not exactly the right person to ask for Python writing style advice.  My code is always a mess.  It works, but it's a mess.

pecenipicek:

--- Quote from: Spicious on April 02, 2014, 04:42:42 am ---First off, go read http://legacy.python.org/dev/peps/pep-0008/ and http://google-styleguide.googlecode.com/svn/trunk/pyguide.html and follow them.

--- End quote ---
i find pep8 to be full of crap in some regards honestly. i've sticked with it mostly even though i find the 4 spaces way too cramped.


--- Quote ---Use the provided logging library instead of rolling your own; it's good: https://docs.python.org/3/howto/logging.html.

--- End quote ---
I've missed that one whilst looking for builtins  :sigh:


--- Quote ---Don't discard exceptions; an object failing to construct really should inform the caller.

--- End quote ---
And what? Have specific handlers in the caller? They are mostly being discarded at the time being anyhow as i hit a bit of a wall on how to proceed in that regard anyhow.
And i'm perfectly fine with them killing the program if they barf on a configuration error. I just need to set up the logging properly.


--- Quote ---Use tuples instead of lists for fixed sized things.

--- End quote ---
Is there  a particular reason for this? And do contents of tuples have to be fixed as well?

--- Quote ---Use list and dict literals ([] and {}) instead of list() and dict().

--- End quote ---
i blame my php background for those... i'll rework it :)

--- Quote ---Don't use __del__ if at all possible.

--- End quote ---
it was the only reliable way to purge the pid on program exit that i could figure out, as running two instances tended to mess some things up fiercely... Do you reccomend a better way?


btw, Kopachris, i'm still open to ideas and reccomendations :)

Navigation

[0] Message Index

Go to full version