On 2016-05-10 23:36, DFS wrote:
[snip]
If lists are still being created:
* at every moment in time, len(list1) returns a length that doesn't
change even if data is added to the list after the call to len().
Example: If the list has 100 items in it at the point len(list) is called:
for i in ra
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 bec
On Mon, 9 May 2016 07:24 am, DFS wrote:
> 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
On Mon, 9 May 2016 07:04 am, DFS wrote:
> 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 a
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.
On Mon, May 9, 2016 at 11:17 AM, 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 requireme
On 05/08/2016 03:07 PM, Chris Angelico wrote:
On Mon, May 9, 2016 at 6:45 AM, Larry Hudson via Python-list
wrote:
On 05/08/2016 06:01 AM, Chris Angelico wrote:
[snip...]
... I like to recommend a
little thing called "IIDPIO debugging" - If In Doubt, Pr
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.
--
Greg
--
https://mail.python.org/mailman/listinfo/p
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.python.org/d
On Mon, May 9, 2016 at 6:49 AM, Dan Sommers wrote:
> On Sun, 08 May 2016 23:01:55 +1000, Chris Angelico wrote:
>
>> ... I like to recommend a little thing called "IIDPIO debugging" - If
>> In Doubt, Print It Out. That means: If you have no idea what a piece
>> of code is doing, slap in a print()
On Mon, May 9, 2016 at 6:45 AM, Larry Hudson via Python-list
wrote:
> On 05/08/2016 06:01 AM, Chris Angelico wrote:
> [snip...]
>>
>> ... I like to recommend a
>> little thing called "IIDPIO debugging" - If In Doubt, Print It Out.
>> That means: If you have
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.python.org/dev/peps/pep-0008/#p
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 something to
On Sun, May 8, 2016 at 5:24 PM, DFS wrote:
> 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
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 something to mimic, its
speaking *only* about *whi
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.xpath('//
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:
var1 = v
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 (pyodbc.Err
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 py
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 over again?
I l
On Sun, 08 May 2016 23:01:55 +1000, Chris Angelico wrote:
> ... I like to recommend a little thing called "IIDPIO debugging" - If
> In Doubt, Print It Out. That means: If you have no idea what a piece
> of code is doing, slap in a print() call somewhere. It'll tell you
> that (a) the code is actu
On 05/08/2016 06:01 AM, Chris Angelico wrote:
[snip...]
... I like to recommend a
little thing called "IIDPIO debugging" - If In Doubt, Print It Out.
That means: If you have no idea what a piece of code is doing, slap in
a print() call somewhere. It'll tel
On Sun, 8 May 2016 02:10 pm, DFS wrote:
> I mean I always use tab after :
>
> The program won't run otherwise. If I use spaces, 100% of the time it
> throws:
>
> IndentationError: unindent does not match any outer indentation level
Then you should be more careful about your spaces. If you inde
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 over again?
Sure, assignments are cheap, but they're
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 (pyodbc.Error) as programError:
>>>
On Sun, May 8, 2016, at 08:06 AM, DFS wrote:
> On 5/8/2016 10:36 AM, Chris Angelico wrote:
> > ... and then you just commit???!?
> >
>
> That's what commit() does.
>
I assure you, he knows what commit does :)
The point is, you don't usually commit after an error happens. You
rollback. Or correc
On Sun, May 8, 2016, at 07:25 AM, DFS wrote:
> for nm,street,city,state,zipcd in zip(nms,street,city,state,zipcd):
> > for vals in zip(nms,street,city,state,zipcd):
> > nm,street,city,state,zipcd = vals
> > cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)"
>
>
> I like the first one bett
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") > 0:
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") > 0:
> dupeRow = True
>
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 version would be:
zi
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,street,city,sta
DFS wrote:
> 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 too
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" (invalid-name)
>> Invalid variable name "rs" (inval
On Sun, May 8, 2016 at 10:50 PM, D'Arcy J.M. Cain
wrote:
> On Sun, 8 May 2016 14:21:49 +1000
> Chris Angelico wrote:
>> if verbose:
>> verbiage = print
>> else:
>> def verbiage(*args): pass
>
> I have never understood why the def couldn't start on the same line as
> the else:
>
> if verbo
On Sun, 8 May 2016 14:21:49 +1000
Chris Angelico wrote:
> if verbose:
> verbiage = print
> else:
> def verbiage(*args): pass
I have never understood why the def couldn't start on the same line as
the else:
if verbose: verbiage = print
else: def verbiage(*args): pass
The colon effectiv
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?
names = addr = tree.xpath()
or if you prefer the old-fashioned:
names = tree.xpath()
addr = names
but that raises the questio
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,street,city,state,zipcd)
> for nm,street,city,st
On Sat, May 7, 2016 at 9:28 PM, DFS wrote:
> But I think there are some pylint bugs here:
> -
>
> standard import "import pyodbc, sqlite3" comes before "import pyodbc,
> sqlite3" (wrong-import-order)
>
> * complains that the
On Sun, May 8, 2016 at 2:40 PM, DFS wrote:
>>> It says "Used builtin function 'filter'. Using a list comprehension can
>>> be
>>> clearer. (bad-builtin)"
>>
>>
>> Kill that message and keep using filter.
>
>
>
> Unfortunately, 'bad-builtin' caught 2 truly bad uses of built-ins (zip() and
> id()),
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" (invalid-name)
Invalid variable name "rs"
On Sun, May 8, 2016 at 2:10 PM, DFS wrote:
>>> +-++
>>> |trailing-whitespace |59 | heh!
>>> +-++
>>> |multiple-statements |23 | do this to save lines.
>>> W
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 comments
+-++
On Sun, May 8, 2016 at 1:38 PM, DFS wrote:
>> This code is reeking with bad habits to be broken. Assigning a throwaway
>> variable to walk the index is unnecessary when Python can do it for you
>> behind the scenes.
>
>
> Don't you think python also allocates a throwaway variable for use with zip
On Sat, May 7, 2016, at 08:28 PM, DFS wrote:
> >> +-++
> >> |superfluous-parens |3 | I like to surround 'or'
> >> statments with parens
> >
> > I would need examples to comment
>
>
> if ("Please choose a
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" (invalid-name)
> Invalid variable name "rs" (invalid-name)
... huh?? The first
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 version would be:
>
> ziplists = zip(nms,street,cit
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 break bad programmi
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 at what it spewed
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 comments
> +-++ ---
> |messa
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]
On Sun, May 8, 2016 at 12:15 PM, DFS wrote:
> On 5/7/2016 9:36 PM, Chris Angelico wrote:
>>
>> On Sun, May 8, 2016 at 11:16 AM, DFS wrote:
>>>
>>> street = [s.split(',')[0] for s in addr]
>>> city = [c.split(',')[1].strip() for c in addr]
>>> state = [s[-8:][:2] for s in addr]
>>> zipcd = [z[
On 2016-05-08 03:14, 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],
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:
names
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], list3[j], etc.
Although Ch
On 5/7/2016 3:52 PM, Ray Cote wrote:
Biggest issue I have with pyLint is that it complains when function
parameters are indented twice vs. once. pyFlakes likes the twice.
Example:
def function_name(
parm_1,
long_parm_name,
….
end_of_long_list_of params)
parm_1
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:
>
> names = tree.xpath()
> addr = tree
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.
enumeration would
On Sun, May 8, 2016 at 4:42 AM, Michael Selik wrote:
>
>> +-++
>> |line-too-long|5 | meh
>>
>
> Yeah, I think 80 characters can be somewhat tight. Still, 5 long lines in
> 200ish lines of code? Sounds like you might be doing too much in tho
On 5/7/2016 12:52 PM, Ray Cote wrote:
I’m impressed with 10/10.
My approach is to ensure flake8 (a combination of pyflakes and pep8
checking) does not report any warnings and then run pyLint as a final
check.
I just installed pyflakes and ran it against my 10/10 files. It's not
complaining ab
On Sat, May 7, 2016 at 2:52 PM, Christopher Reimer <
christopher_rei...@icloud.com> 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
> idiosyncrat
On 5/7/2016 12:23 PM, Stephen Hansen wrote:
On Sat, May 7, 2016, at 11:52 AM, Christopher Reimer wrote:
You can do better. You should strive for 10/10 whenever possible,
figure out why you fall short and ask for help on the parts that don't
make sense.
I think this is giving far too much weigh
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 suppose the answer is that it did find a few things to check. You
might be happier with pychecker, which is m
On Sat, May 7, 2016, at 11:52 AM, Christopher Reimer wrote:
> You can do better. You should strive for 10/10 whenever possible,
> figure out why you fall short and ask for help on the parts that don't
> make sense.
I think this is giving far too much weight to pylint's opinion on what
is "good"
Pylint is very opinionated. Feel free to adjust its configuration to
suit your opinions of style.
In particular, several of these might be related to PEP8 style issues.
On Sat, May 7, 2016, at 09:51 AM, DFS wrote:
>DFS comments
> +--
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 break bad programming
habits. Since I came from a Java background
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 pylint and try it out. If it teaches me ev
On Sat, May 7, 2016 at 12:56 PM DFS wrote:
> |mixed-indentation|186 | I always use tab
>
Don't mix tabs and spaces. I suggest selecting all lines and using your
editor to convert spaces to tabs. Usually there's a feature to "tabify".
> +-++
>
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.
>
> enumeration would be:
> for j,item in enumerate(
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 |
+==
69 matches
Mail list logo