pylint woes

2016-05-07 Thread DFS
This more-anal-than-me program generated almost 2 warnings for every line of code in my program. w t hey? DFS comments +-++ --- |message id |occurrences

Re: pylint woes

2016-05-07 Thread DFS
On 5/7/2016 1:01 PM, Chris Angelico wrote: On Sun, May 8, 2016 at 2:51 AM, DFS wrote: [1] pylint says "Consider using enumerate instead of iterating with range and len" the offending code is: for j in range(len(list1)): do something with list1[j], list2[j], list3[j], etc. enumera

Re: pylint woes

2016-05-07 Thread DFS
On 5/7/2016 9:36 PM, Chris Angelico wrote: On Sun, May 8, 2016 at 11:16 AM, DFS wrote: On 5/7/2016 1:01 PM, Chris Angelico wrote: The suggestion from a human would be to use zip(), or possibly to change your data structures. Happens like this: address data is scraped from a website

Re: pylint woes

2016-05-07 Thread DFS
On 5/7/2016 10:14 PM, Stephen Hansen wrote: On Sat, May 7, 2016, at 06:16 PM, DFS wrote: Why is it better to zip() them up and use: for item1, item2, item3 in zip(list1, list2, list3): do something with the items than for j in range(len(list1)): do something with list1[j], list2[j

Re: pylint woes

2016-05-07 Thread DFS
On 5/7/2016 3:40 PM, Terry Reedy wrote: On 5/7/2016 12:51 PM, DFS wrote: This more-anal-than-me program generated almost 2 warnings for every line of code in my program. w t hey? If you don't like it, why do you use it? I've never used it before last night. I was shocked

Re: pylint woes

2016-05-07 Thread DFS
On 5/7/2016 2:52 PM, Christopher Reimer wrote: On 5/7/2016 9:51 AM, DFS wrote: Has anyone ever in history gotten 10/10 from pylint for a non-trivial program? I routinely get 10/10 for my code. While pylint isn't perfect and idiosyncratic at times, it's a useful tool to help

Re: pylint woes

2016-05-07 Thread DFS
On 5/7/2016 11:25 PM, Steven D'Aprano wrote: On Sun, 8 May 2016 02:51 am, DFS wrote: This more-anal-than-me program generated almost 2 warnings for every line of code in my program. w t hey? DFS com

Re: pylint woes

2016-05-07 Thread DFS
On 5/7/2016 11:51 PM, Chris Angelico wrote: On Sun, May 8, 2016 at 1:28 PM, DFS wrote: Invalid constant name "cityzip" (invalid-name) Invalid constant name "state" (invalid-name) Invalid constant name "miles" (invalid-name) Invalid constant name "store"

Re: pylint woes

2016-05-08 Thread DFS
On 5/7/2016 11:46 PM, Stephen Hansen wrote: On Sat, May 7, 2016, at 08:04 PM, DFS wrote: The lists I actually use are: for j in range(len(nms)): cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)" vals = nms[j],street[j],city[j],state[j],zipcd[j] The enumerated versio

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 1:50 AM, Jussi Piitulainen wrote: DFS writes: The lists I actually use are: for j in range(len(nms)): cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)" vals = nms[j],street[j],city[j],state[j],zipcd[j] The enumerated version would be: ziplists = zip(nms,s

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 10:36 AM, Chris Angelico wrote: On Mon, May 9, 2016 at 12:25 AM, DFS wrote: for category,name,street,city,state,zipcode in ziplists: try: db.execute(cSQL, vals) except (pyodbc.Error) as programError: if str(programError).find("UNIQUE constraint failed&

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 11:51 AM, Steven D'Aprano wrote: On Mon, 9 May 2016 12:25 am, DFS wrote: for j in range(len(nms)): cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)" vals = nms[j],street[j],city[j],state[j],zipcd[j] Why are you assigning cSQL to the same string over and

Re: pylint woes

2016-05-08 Thread DFS
On 5/7/2016 2:43 PM, Peter Pearson wrote: On Sat, 7 May 2016 12:51:00 -0400, DFS wrote: This more-anal-than-me program generated almost 2 warnings for every line of code in my program. w t hey? Thank you for putting a sample of pylint output in front of my eyes; you inspired me to install

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 11:15 AM, Chris Angelico wrote: On Mon, May 9, 2016 at 1:06 AM, DFS wrote: On 5/8/2016 10:36 AM, Chris Angelico wrote: On Mon, May 9, 2016 at 12:25 AM, DFS wrote: for category,name,street,city,state,zipcode in ziplists: try: db.execute(cSQL, vals) except

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 1:25 PM, Steven D'Aprano wrote: On Sun, 8 May 2016 02:10 pm, DFS wrote: +-++ |bad-whitespace |65 | mostly because I line up = signs:

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 7:36 AM, Steven D'Aprano wrote: On Sun, 8 May 2016 11:16 am, DFS wrote: address data is scraped from a website: names = tree.xpath() addr = tree.xpath() Why are you scraping the data twice? Because it exists in 2 different sections of the document. names = tree.

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 5:38 PM, Stephen Hansen wrote: On Sun, May 8, 2016, at 02:16 PM, DFS wrote: I was surprised to see the PEP8 guide approve of: "Yes: if x == 4: print x, y; x, y = y, x" https://www.python.org/dev/peps/pep-0008/#pet-peeves That is not approving of that line of code as so

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 6:05 PM, Stephen Hansen wrote: On Sun, May 8, 2016, at 02:46 PM, DFS wrote: On 5/8/2016 5:38 PM, Stephen Hansen wrote: On Sun, May 8, 2016, at 02:16 PM, DFS wrote: I was surprised to see the PEP8 guide approve of: "Yes: if x == 4: print x, y; x, y = y, x" https://www.

Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-08 Thread DFS
sSQL = "line 1\n" sSQL += "line 2\n" sSQL += "line 3" -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-08 Thread DFS
On 5/8/2016 9:17 PM, Gregory Ewing wrote: Stephen Hansen wrote: The point is, you don't usually commit after an error happens. You rollback. He might want to commit the ones that *did* go in. That's not necessarily wrong. It all depends on the surrounding requirements and workflow. Bingo.

Is there a reason zip() wipes out data?

2016-05-08 Thread DFS
python 2.7.11 docs: "The returned list is truncated in length to the length of the shortest argument sequence." a = ['who','let','the'] b = ['dogs','out?'] c = zip(a,b) print c [('who', 'dogs'), ('let', 'out?')] Wouldn't it be better to return an empty element than silently kill your data?

Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-10 Thread DFS
On 5/9/2016 3:53 AM, Steven D'Aprano wrote: On Monday 09 May 2016 09:10, DFS wrote: sSQL = "line 1\n" sSQL += "line 2\n" sSQL += "line 3" Pointlessly provocative subject line edited. huh? You call

The irony

2016-05-10 Thread DFS
"There should be one-- and preferably only one --obvious way to do it." https://www.python.org/dev/peps/pep-0020/ --- sSQL = "line 1\n" sSQL += "line 2\n" sSQL += "line 3" --- sSQL = ("line 1\n" "line 2\n" "line 3"

Re: An educational site written in Python (from YCombinator's RFS)

2016-05-10 Thread DFS
On 5/10/2016 2:13 AM, Cai Gengyang wrote: Ok, so after reading YCombinator's RFS, I have decided that I want to work on this : --- EDUCATION If we can fix education, we can eventua

Re: Pylint prefers list comprehension over filter...

2016-05-10 Thread DFS
On 5/10/2016 3:34 PM, Terry Reedy wrote: On 5/10/2016 9:51 AM, Claudiu Popa wrote: Thank you for letting us know. While pylint is indeed opinionated in some cases, we're not trying to be "arrogant", as you put it, towards Guido or the other core developers. What's sad in this particular case is

Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-10 Thread DFS
On 5/10/2016 2:15 PM, Ian Kelly wrote: On Tue, May 10, 2016 at 10:16 AM, DFS wrote: On 5/9/2016 3:53 AM, Steven D'Aprano wrote: On Monday 09 May 2016 09:10, DFS wrote: sSQL = "line 1\n" sSQL += "line 2\n" sSQL += "line 3" Pointlessly provocative

Re: pylint woes

2016-05-10 Thread DFS
On 5/7/2016 10:50 PM, Chris Angelico wrote: On Sun, May 8, 2016 at 12:15 PM, DFS wrote: The only reason for j in range(len(list1)): do something with list1[j], list2[j], list3[j], etc. or for item1, item2, item3 in zip(list1, list2, list3): do something with the items works is

<    1   2