Re: Looping on a list in json

2017-11-04 Thread Sayth Renshaw
no doubt tho after playing with this is that enumerate value ends up in the output which is a dictionary. The enumerate has no key which makes it invalid json if dumped. Not massive issue but getting the effect of enumerate without polluting output would be the winner. >runner_lists = {}

Specialization for learning python from university of Michigan school of information

2017-11-04 Thread fatma . fars33
https://youtu.be/eblAxa5iO24. The video is just an introduction for a course on https://studyscienceblog.wordpress.com/2017/10/28/university-of-mitchigan-s-courses -- https://mail.python.org/mailman/listinfo/python-list

Re: replacing `else` with `then` in `for` and `try`

2017-11-04 Thread Steve D'Aprano
On Sat, 4 Nov 2017 04:44 am, Jon Ribbens wrote: > On 2017-11-03, Steve D'Aprano wrote: >> The for loop does not necessarily perform a search: >> >> count = 1 >> for obj in sequence: >> if count > MAX_OBJECTS: >> print("too many objects, halting") >> break >> process(obj) >

Zen of Python “obvious way to do it” (was: [TSBOAPOOOWTDI]using names from modules)

2017-11-04 Thread Ben Finney
Steve D'Aprano writes: > On Sun, 5 Nov 2017 06:42 am, Stefan Ram wrote: > > > What is the one way to do it? > > There is no philosophy of "one way to do it" in Python, that is a > misunderstanding (possibly deliberate...) spread about by Perl users, > to contrast Python from Perl's "more than one

Re: Read Firefox sqlite files with Python

2017-11-04 Thread Steve D'Aprano
On Sun, 5 Nov 2017 04:32 am, Steve D'Aprano wrote: > I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5. > > > import sqlite3 > con = sqlite3.connect('foo.sqlite') > with open('dump.sql', 'w') as f: > for line in con.iterdump(): > f.write(line + '\n') Never m

Re: [TSBOAPOOOWTDI]using names from modules

2017-11-04 Thread Steve D'Aprano
On Sun, 5 Nov 2017 06:42 am, Stefan Ram wrote: > What is the one way to do it? There is no philosophy of "one way to do it" in Python, that is a misunderstanding (possibly deliberate...) spread about by Perl users, to contrast Python from Perl's "more than one way to do it". The Zen of Python sa

Re: python3 byte decode

2017-11-04 Thread Cameron Simpson
On 04Nov2017 01:47, Chris Angelico wrote: On Fri, Nov 3, 2017 at 8:24 PM, Ali Rıza KELEŞ wrote: Yesterday, while working with redis, i encountered a strange case. I want to ask why is the following `True` ``` "s" is b"s".decode() ``` while the followings are `False`? ``` "so" is b"so".deco

Re: [TSBOAPOOOWTDI]using names from modules

2017-11-04 Thread Terry Reedy
On 11/4/2017 3:42 PM, Stefan Ram wrote: What is better: ... import math ... ... math.cos ... ... or ... from math import cos ... ... cos ... ... ? (To me, the first is more readable, because at the site where »math.cos« is used, it is made clear that »cos« comes from math.

Re: Looping on a list in json

2017-11-04 Thread Cameron Simpson
On 04Nov2017 17:43, Sayth Renshaw wrote: figured it. Needed to use n to iterate when creating. Yeah, my mistake. runner_lists = {} for n, item in enumerate(result): # if this one is interested / not -filtered: print(n, item) runner_lists[n] = result[n]["RacingFormGuid

Re: Looping on a list in json

2017-11-04 Thread Sayth Renshaw
Sorry figured it. Needed to use n to iterate when creating. runner_lists = {} for n, item in enumerate(result): # if this one is interested / not -filtered: print(n, item) runner_lists[n] = result[n]["RacingFormGuide"]["Event"]["Runners"] Sayth -- https://mail.python

Re: Looping on a list in json

2017-11-04 Thread Sayth Renshaw
> I'd just keep the interesting runners, along with their race numbers, in a > dict. The enumerate function is handy here. Something like (untested): > > runner_lists = {} > for n, item in enumerate(result): > if this one is interested/not-filtered: > runner_lists[n] = result["Raci

Re: Aw: Try: Except: evaluates to True every time

2017-11-04 Thread Steve D'Aprano
On Sun, 5 Nov 2017 03:07 am, Karsten Hilbert wrote: > Try in an interactive interpreter: > >python> "a string" is True Did you try that yourself? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailm

Re: Ideas about how software should behave

2017-11-04 Thread Ben Finney
Jon Ribbens writes: > On 2017-11-04, Ben Finney wrote: > > To respond to the criticism of an idea – criticism containing no > > mention of the person – as though it “clearly refers to the > > [person]”, is of significant concern on a software dicussion forum > > such as this. > > No, the thing t

Re: Read Firefox sqlite files with Python

2017-11-04 Thread Sayth Renshaw
On Sunday, 5 November 2017 04:32:26 UTC+11, Steve D'Aprano wrote: > I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5. > > > import sqlite3 > con = sqlite3.connect('foo.sqlite') > with open('dump.sql', 'w') as f: > for line in con.iterdump(): > f.write(line +

Re: Looping on a list in json

2017-11-04 Thread Sayth Renshaw
On Sunday, 5 November 2017 09:53:37 UTC+11, Cameron Simpson wrote: > >I want to get a result from a largish json api. One section of the json > >structure returns lists of data. I am wanting to get each resulting list > >returned. > > > >This is my code. > >import json > >from pprint import ppr

Re: [TSBOAPOOOWTDI]using names from modules

2017-11-04 Thread Cameron Simpson
On 04Nov2017 20:59, Peter J. Holzer wrote: On 2017-11-04 19:42, Stefan Ram wrote: What is better: ... import math ... ... math.cos ... or ... from math import cos ... ... cos ... ? (To me, the first is more readable, because at the site where »math.cos« is used, it is made clear th

Re: Looping on a list in json

2017-11-04 Thread Cameron Simpson
On 04Nov2017 14:01, Sayth Renshaw wrote: I want to get a result from a largish json api. One section of the json structure returns lists of data. I am wanting to get each resulting list returned. This is my code. import json from pprint import pprint with open(r'/home/sayth/Projects/results/

Looping on a list in json

2017-11-04 Thread Sayth Renshaw
Hi I want to get a result from a largish json api. One section of the json structure returns lists of data. I am wanting to get each resulting list returned. This is my code. import json from pprint import pprint with open(r'/home/sayth/Projects/results/Canterbury_2017-01-20.json', 'rb') as f

Re: [TSBOAPOOOWTDI]using names from modules

2017-11-04 Thread Peter J. Holzer
On 2017-11-04 19:42, Stefan Ram wrote: > What is better: > > ... > import math > ... > ... math.cos ... > ... > > or > > ... > from math import cos > ... > ... cos ... > ... > > ? > > (To me, the first is more readable, because at the site > where »math.cos« is used, it is made clear tha

Re: right list for SIGABRT python binary question ?

2017-11-04 Thread Karsten Hilbert
On Fri, Nov 03, 2017 at 07:31:56AM +0100, dieter wrote: > > I have posted backtraces taken from the address being > > watched. Does that help any at all ? > > Only in the case that the error is "local", i.e. detected > (quite) immediately. > > You might be in this case as you have observed that

Re: Try: Except: evaluates to True every time

2017-11-04 Thread Karsten Hilbert
On Sat, Nov 04, 2017 at 05:07:26PM +0100, Karsten Hilbert wrote: > Try in an interactive interpreter: > >python> "a string" is True Or, rather, python> if 'a string': print 'success' Sorry, Karsten -- GPG key ID E4071346 @ eu.pool.sks-keyservers.net E167 67FD A291 2BEA 73BD 4537

Re: Read Firefox sqlite files with Python

2017-11-04 Thread Peter Otten
Steve D'Aprano wrote: > I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5. > > > import sqlite3 > con = sqlite3.connect('foo.sqlite') > with open('dump.sql', 'w') as f: > for line in con.iterdump(): > f.write(line + '\n') > > > The error I get is: > > Trace

Aw: Try: Except: evaluates to True every time

2017-11-04 Thread Karsten Hilbert
Try in an interactive interpreter: python> "a string" is True Karsten > Gesendet: Samstag, 04. November 2017 um 16:31 Uhr > Von: "brandon wallace" > An: python-list@python.org > Betreff: Try: Except: evaluates to True every time > > > I have this code that tests a server to see if it is lis

Read Firefox sqlite files with Python

2017-11-04 Thread Steve D'Aprano
I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5. import sqlite3 con = sqlite3.connect('foo.sqlite') with open('dump.sql', 'w') as f: for line in con.iterdump(): f.write(line + '\n') The error I get is: Traceback (most recent call last): File "", line 2,

Re: Try: Except: evaluates to True every time

2017-11-04 Thread Steve D'Aprano
On Sun, 5 Nov 2017 02:31 am, brandon wallace wrote: > > I have this code that tests a server to see if it is listening on port 123 > runs and evaluates to True every time. Even if the server does not exist but > it is not supposed to do that. I am getting no error message at all. What is > going

Try: Except: evaluates to True every time

2017-11-04 Thread brandon wallace
I have this code that tests a server to see if it is listening on port 123 runs and evaluates to True every time. Even if the server does not exist but it is not supposed to do that. I am getting no error message at all. What is going on with this code?     #!/usr/bin/env python import socket

Re: Try: Except: evaluates to True every time

2017-11-04 Thread Chris Angelico
On Sun, Nov 5, 2017 at 2:31 AM, brandon wallace wrote: > > I have this code that tests a server to see if it is listening on port 123 > runs and evaluates to True every time. Even if the server does not exist but > it is not supposed to do that. I am getting no error message at all. What is > g

Re: replacing `else` with `then` in `for` and `try`

2017-11-04 Thread Chris Angelico
On Sat, Nov 4, 2017 at 11:22 PM, Jon Ribbens wrote: > On 2017-11-04, Michael Torrie wrote: >> On 11/03/2017 09:06 PM, Chris Angelico wrote: >>> On Sat, Nov 4, 2017 at 1:57 PM, Michael Torrie wrote: On 11/03/2017 07:09 PM, Steve D'Aprano wrote: > That's incorrect. There are multiple ways

Re: matplot plot hangs

2017-11-04 Thread Andrew Z
Tim, it won't even advance to that line. On Thu, Nov 2, 2017 at 8:28 AM, Tim Williams wrote: > On Wednesday, November 1, 2017 at 6:30:27 PM UTC-4, Andrew Z wrote: > > nope. it doesnt: > > > > I added print-s after each line and that produced: > > [az@hp src]$ cat ./main1.py > > import matplotli

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-04 Thread Chris Angelico
On Sat, Nov 4, 2017 at 11:25 PM, Jon Ribbens wrote: > On 2017-11-04, Ben Finney wrote: >> To respond to the criticism of an idea – criticism containing no mention >> of the person – as though it “clearly refers to the [person]”, is of >> significant concern on a software dicussion forum such as t

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-04 Thread Jon Ribbens
On 2017-11-04, Ben Finney wrote: > To respond to the criticism of an idea – criticism containing no mention > of the person – as though it “clearly refers to the [person]”, is of > significant concern on a software dicussion forum such as this. No, the thing that is "of significant conern on a so

Re: replacing `else` with `then` in `for` and `try`

2017-11-04 Thread Jon Ribbens
On 2017-11-04, Michael Torrie wrote: > On 11/03/2017 09:06 PM, Chris Angelico wrote: >> On Sat, Nov 4, 2017 at 1:57 PM, Michael Torrie wrote: >>> On 11/03/2017 07:09 PM, Steve D'Aprano wrote: That's incorrect. There are multiple ways to exit a loop that will prevent the `else` block fro