Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Laura Creighton
The fact that _ and __ are intended as throw away values is only clear to people who have read a particular doc about coding styles. If you haven't read the doc, you don't know what is going on. I name my throw away variables junk, and if there are lots of them, for instance when I am reading fro

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Alan Gauld
On 30/04/15 20:22, Roel Schroeven wrote: Alan Gauld schreef op 2015-04-30 00:51: Summarizing a bit, I think you make two main points (please correct me if I'm wrong): Your quite correct. I'm probably a bit paranoid but as I said I spent a significant bit of my production-programming career

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Roel Schroeven
Dave Angel schreef op 2015-04-30 21:33: Well, are you aware that _ has a meaning in the debugger? It holds the last value of an expression that wasn't assigned to a variable. or something like that. Yes, I know the meaning of _ in Python's interactive mode. It's something I sometimes use fo

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Dave Angel
On 04/30/2015 03:22 PM, Roel Schroeven wrote: Alan Gauld schreef op 2015-04-30 00:51: > ... Trying to visually scan for _ or even __ is hard. Also different fonts make _ and __ hard to distinguish. > ... But they will be. Almost for certain. It's human nature and the nature of code maint

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Roel Schroeven
Alan Gauld schreef op 2015-04-30 00:51: > ... Trying to visually scan for _ or even __ is hard. Also different fonts make _ and __ hard to distinguish. > ... But they will be. Almost for certain. It's human nature and the nature of code maintenance. If it's there somebody will find a use fo

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-29 Thread Alan Gauld
On 29/04/15 22:11, Roel Schroeven wrote: Alan Gauld schreef op 2015-04-29 18:43: On 29/04/15 17:03, Jugurtha Hadjar wrote: http://docs.python-guide.org/en/latest/writing/style/#create-an-ignored-variable I've seen this before and strongly disagree with it. I disagree with your disagreement

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-29 Thread Jugurtha Hadjar
On 04/29/2015 09:50 AM, Peter Otten wrote: My random observations: (1) find() and create() look very similar. Try hard to factor out common code. You might even combine it into a single method ensure_balance(phone). I'll think about it. I can't see for now how I would combine the two (each

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-29 Thread Roel Schroeven
Alan Gauld schreef op 2015-04-29 18:43: On 29/04/15 17:03, Jugurtha Hadjar wrote: http://docs.python-guide.org/en/latest/writing/style/#create-an-ignored-variable I've seen this before and strongly disagree with it. I disagree with your disagreement. I'll try to explain. They are ambiguous

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-29 Thread Alan Gauld
On 29/04/15 17:03, Jugurtha Hadjar wrote: (__, cursor) = self.init_db() Don't use the __ 'variable' here, be explicit, it makes maintenance much easier. I actually searched specifically for something like this. In MATLAB, there's the ~ that does this. I'm not trying to write Python

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-29 Thread Jugurtha Hadjar
On 04/29/2015 09:06 AM, Alan Gauld wrote: In principle its an acceptable strategy. A close alternative would be to name the queries as explicit class variables. So for example you would use: cur.execute(self.find_phone_query,()) Its less typing and less error prone in that you get a syntax

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-29 Thread Peter Otten
Jugurtha Hadjar wrote: > I have a class with methods that access a database (SQLite3). I have > included an excerpt showin reading and writing and would like to know if > I'm doing it right. (i.e: Is it bad code and what to improve). > > Here are some improvements and my rationale (check my thi

Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-29 Thread Alan Gauld
On 29/04/15 04:06, Jugurtha Hadjar wrote: - Initially, each method had its SQL statement(s) inside, but I grouped all statements in a dictionary, with operations as keys, as a class 'constant' as per previous advice on this mailing list. We can't see that in the code you posted. In principle i

[Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-28 Thread Jugurtha Hadjar
Hello, all.. I have a class with methods that access a database (SQLite3). I have included an excerpt showin reading and writing and would like to know if I'm doing it right. (i.e: Is it bad code and what to improve). Here are some improvements and my rationale (check my thinking): - Initial