Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 23:22, Martin A. Brown wrote: arr = json.loads('{ "name": "Joe", "address": "111 Street" }') arr.get('address') Here are some notes about why: # -- You will notice I used a variable called 'arr' instead of #array, because there is a module called array, and I may

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Steven D'Aprano
On Thu, Dec 11, 2014 at 02:25:53PM -0600, Galen Seilis wrote: > I would appreciate assitance understanding why this doesn't work, and how I > can get up-and-running with inputing JSON code into Python. Did you try reading the Fine Manual? It has many examples! For Python 2: https://docs.python.o

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Ben Finney
Alan Gauld writes: > On 11/12/14 23:15, Ben Finney wrote: > > >> *array = json.load( { "name": "Joe", "address": "111 Street" } )* > > > > You are passing a Python dict value to the function. JSON is a > > serialisation format, and the input to ‘json.load’ must be a text > > string. > > Nope, its

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Martin A. Brown
Hello there, To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, in File "C:\Python27\lib

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 23:15, Ben Finney wrote: *array = json.load( { "name": "Joe", "address": "111 Street" } )* You are passing a Python dict value to the function. JSON is a serialisation format, and the input to ‘json.load’ must be a text string. Nope, its a file-like object. The input to loads()

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Alan Gauld
On 11/12/14 20:25, Galen Seilis wrote: To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, i

Re: [Tutor] Parsing JSON with Python

2014-12-11 Thread Ben Finney
Galen Seilis writes: > I am having difficulty interacting with JSON. The example below if a > typical input and output: Thank you for presenting a simple example and the resulting output. Unfortunately, your mail client has mangled it, inserting asterisks making syntax errors, and wrapping line

[Tutor] Parsing JSON with Python

2014-12-11 Thread Galen Seilis
To whom it may concern, I am having difficulty interacting with JSON. The example below if a typical input and output: *import json* *array = json.load( { "name": "Joe", "address": "111 Street" } )* *Traceback (most recent call last): File "" , line 1, in File "C:\Python27\lib\json\__init__.py

Re: [Tutor] While Loop Help

2014-12-11 Thread James Chapman
While Alan has given you a far better solution, I feel someone should mention the break statement as you will likely come across it a lot, and it is quite an important flow control statement. You could add a break statement to the else which would break out of the while loop. https://docs.python.o

Re: [Tutor] Does the user need to install Python, when we deploy our c++ products using python?

2014-12-11 Thread James Chapman
On 2 December 2014 at 20:28, gordon zhang wrote: > > > I downloaded python 3.4.2 for c++ and create a vc++ project using python, > but I have no idea what python dlls and other stuff needed to deploy the > products. > > I know if we put Python34.dll and Python.dll in the folder of executable, > i

Re: [Tutor] cx_Oracle and Pyinstaller

2014-12-11 Thread Steven D'Aprano
On Wed, Dec 10, 2014 at 06:42:38PM -0600, Bill Allen wrote: > I have had success with producing a single file executable from a Python > script that includes cx_Oracle. Here are the details. Hopefully this will > also help someone struggling to get this working. [...] Thanks Bill! This may be a

Re: [Tutor] Does the user need to install Python, when we deploy our c++ products using python?

2014-12-11 Thread James Chapman
Actually, after re-reading your original message I think I misunderstood and went off on a tangent. If you are embedding python into a C++ app, then you will need the dlls and all of the compiled python code. *.pyc. (Well most, not all). The exact location of these files in the final build I'm uns

Re: [Tutor] While Loop Help

2014-12-11 Thread Steven D'Aprano
On Wed, Dec 10, 2014 at 11:20:12PM -0500, Matthew Nappi wrote: > I am working on the challenges from “Python Programming for the Absolute > Beginner” Chapter 3. I am asked to modify the original code pasted below > to limit the number of guesses a player has to guess the number. I did so > (code

Re: [Tutor] While Loop Help

2014-12-11 Thread Alan Gauld
On 11/12/14 04:20, Matthew Nappi wrote: (code pasted below); however if a player guesses the right number they still receive an ending message indicating that they failed. How can I modify the code without using any advanced techniques to have a different message in the event of a successful gu

[Tutor] While Loop Help

2014-12-11 Thread Matthew Nappi
Hello All: I am working on the challenges from “Python Programming for the Absolute Beginner” Chapter 3. I am asked to modify the original code pasted below to limit the number of guesses a player has to guess the number. I did so (code pasted below); however if a player guesses the right numb