errors with json.loads

2017-09-20 Thread john polo
Greetings, I am using IPython 6.1.0 with Python 3.6.2 on a Windows 7 machine. I am not a programmer. I am using a book called Python Data Analytics to try to learn some of Python. I am at a section for reading and writing JSON data. The example JSON file is: Listing 5-13.  books.json [{"wri

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/20/2017 5:56 PM, John Gordon wrote: In john polo writes: JSONDecodeError: Expecting ':' delimiter: line 5 column 50 (char 161) ?json.loads says that the method is for deserializing "s", with "s" being a string, bytes, or bytearray. In [24]: type(text) Out[

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/20/2017 5:58 PM, Bill wrote: Interesting problem, John. I have probably even less experience with json than you do, so I'm taking this as an opportunity to learn with you. Suggestions: 1. Try your example with Python 2 rather than Python 3. Bill, Thanks for the reply. I wasn't sure how

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/20/2017 6:40 PM, Dennis Lee Bieber wrote: On Wed, 20 Sep 2017 17:13:41 -0500, john polo declaimed the following: and the example code for reading the file is: file = open('books.json','r') What encoding is the file? I did a cut&paste from your p

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/21/2017 4:24 AM, Thomas Jollans wrote: It looks to me like the root cause of the problem was that they copied the code from a web page, and the web page contained invalid JSON. Thank you, Thomas. John -- https://mail.python.org/mailman/listinfo/python-list

Re: Re: errors with json.loads

2017-09-21 Thread john polo
On 9/21/2017 10:11 AM, Ned Batchelder wrote: I can only assume that the actual data being read is different than the data they put into the message here. --Ned. There was a typo in the file that I had made and saved; an extra comma before one of the ":". Apologies to the list for not catchi

TypeError with map with no len()

2017-09-25 Thread john polo
Python List, I am trying to make practice data for plotting purposes. I am using Python 3.6. The instructions I have are import matplotlib.pyplot as plt import math import numpy as np t = np.arange(0, 2.5, 0.1) y1 = map(math.sin, math.pi*t) plt.plot(t,y1) However, at this point, I get a TypeE

Re: TypeError with map with no len()

2017-09-25 Thread john polo
On 9/25/2017 12:03 PM, Paul Moore wrote: You're using Python 3, and I suspect that you're working from instructions that assume Python 2. In Python 3, the result of map() is a generator, not a list (which is what Python 2's map returned). In order to get an actual list (which appears to be what y

Re: TypeError with map with no len()

2017-09-26 Thread john polo
On 9/25/2017 5:37 PM, Thomas Jollans wrote: On 25/09/17 18:44, john polo wrote: Python List, I am trying to make practice data for plotting purposes. I am using Python 3.6. The instructions I have are import matplotlib.pyplot as plt import math import numpy as np t = np.arange(0, 2.5, 0.1) y1

Re: The "loop and a half"

2017-10-04 Thread john polo
On 10/3/2017 5:08 PM, Stefan Ram wrote: Steve D'Aprano writes: On Wed, 4 Oct 2017 04:45 am, Rhodri James wrote: On 03/10/17 18:29, Stefan Ram wrote: Is this the best way to write a "loop and a half" in Python? Define "best". I'd start with "define loop and a half". I encountered this ph

syntax error in first-time user script

2017-03-24 Thread john polo
Greetings, I am attempting to learn Python. I have no programming background. I'm on a computer with Windows 7. I checked the PATH in System Variables and Python and Python\Scripts are in the path. I have a book, Python for Biologists and it supplies example scripts, one is called comment.py.

Re: syntax error in first-time user script

2017-03-24 Thread john polo
On 3/24/2017 9:11 AM, Bob Gailer wrote: On Mar 24, 2017 4:53 AM, "john polo" <mailto:jp...@mail.usf.edu>> wrote: > > Greetings, > I am attempting to learn Python. I have no programming background. I'm on a computer with Windows 7. I checked the PATH in System

Re: syntax error in first-time user script

2017-03-25 Thread john polo
I had a misconception of how the Python interpreter works. If I have a script, call it example.py, in order to run it, I shouldn't be in the interpreter? In other words, I should be at the Windows command prompt, for example C:/test> python example.py and not >>> python example.py ? So, if

read in a list in a file to list

2017-04-08 Thread john polo
Hi, I am using Python 3.6 on Windows 7. I have a file called apefile.txt. apefile.txt's contents are: apes = "Home sapiens", "Pan troglodytes", "Gorilla gorilla" I have a script: apefile = open("apefile.txt") apelist = apefile.read() for ape in apelist: print("one of the apes is " + ape

Re: read in a list in a file to list

2017-04-09 Thread john polo
On 4/8/2017 3:21 PM, breamore...@gmail.com wrote: On Saturday, April 8, 2017 at 7:32:52 PM UTC+1, john polo wrote: Hi, I am using Python 3.6 on Windows 7. I have a file called apefile.txt. apefile.txt's contents are: apes = "Home sapiens", "Pan troglodytes", &q

script output appears correct but still raises AssertionError

2017-06-06 Thread john polo
Python People, I am learning about assertions. I wrote a small script that takes 2 inputs, an amino acid sequence and one residue symbol. The script should return what percent of the sequence is residue in output. The point of this script is to use assert for debugging. My script seems to work

Re: script output appears correct but still raises, AssertionError

2017-06-07 Thread john polo
ChrisA, Thank you for pointing out my error: using print() when I should have used return(). John -- https://mail.python.org/mailman/listinfo/python-list