Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Marko Rauhamaa
Mark Lawrence : > 1) I was being facetious. > 2) How many times do people have to be asked not to top post here > before they stop top posting? > 3) I only have two things to say so this is superfluous. Mark, it may not be your objective, but you really are poisoning the atmosphere here. Marko

Re: Finding scores from a list

2015-11-24 Thread Mark Lawrence
On 24/11/2015 13:25, Cai Gengyang wrote: results = [ {"id": 1, "name": "ensheng", "score": 10}, {"id": 2, "name": "gengyang", "score": 12}, {"id": 3, "name": "jordan", "score": 5}, ] I want to find gengyang's score. This is what I tried : print((results["gengyang"])["score"]) but I got an e

Re: What is a function parameter =[] for?

2015-11-24 Thread Antoon Pardon
Op 19-11-15 om 19:20 schreef Mark Lawrence: > On 19/11/2015 17:30, BartC wrote: >> On 19/11/2015 16:01, Steven D'Aprano wrote: >>> On Fri, 20 Nov 2015 12:19 am, BartC wrote: >> >>> You know, for somebody who claims to design and implement your own >>> languages, you sometimes go to a remarkable eff

Re: Finding scores from a list

2015-11-24 Thread Peter Otten
Cai Gengyang wrote: > > results = [ > {"id": 1, "name": "ensheng", "score": 10}, > {"id": 2, "name": "gengyang", "score": 12}, > {"id": 3, "name": "jordan", "score": 5}, > ] > > I want to find gengyang's score. This is what I tried : > print((results["gengyang"])["score"]) > > but I got a

Re: What is a function parameter =[] for?

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 12:43 AM, Antoon Pardon wrote: > I think that part of the problem is, that [] is not a constant object. So > that when you see a line like > > ls = [] > > It behaves more lke > > ls = [].copy() > > than what you would expect with the normal python semantics. You're

Multiprocessing PyPy-CPython

2015-11-24 Thread LJ
Hi everyone. Im trying to solve some problems in parallel using the multiprocessing module in Python 2.7. A general model is built using CPython and then the subproblems are solved in parallel returning results in a queue. This is currently working fine. I would like to solve the subproblems us

Re: Returning a result from 3 items in a list

2015-11-24 Thread Denis McMahon
On Tue, 24 Nov 2015 02:04:56 -0800, Cai Gengyang wrote: > Here's a dictionary with 3 values : > > results = { > "gengyang": 14, > "ensheng": 13, "jordan": 12 > } > > How do I define a function that takes the last of the 3 items in that > list and returns Jordan's results i.e. (12) ? You ope

Re: Finding scores from a list

2015-11-24 Thread BartC
On 24/11/2015 13:25, Cai Gengyang wrote: results = [ {"id": 1, "name": "ensheng", "score": 10}, {"id": 2, "name": "gengyang", "score": 12}, {"id": 3, "name": "jordan", "score": 5}, ] I want to find gengyang's score. This is what I tried : print((results["gengyang"])["score"]) but I got an e

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Denis McMahon
On Tue, 24 Nov 2015 03:04:09 -0800, Cai Gengyang wrote: > results = { > "gengyang": { "maths": 10, "english": 15}, > "ensheng": {"maths": 12, "english": 10}, "jordan": {"maths": 9, > "english": 13} > } > > How do you get gengyang's maths scores ? I refer to my previous answer. Open a web

Re: What is a function parameter =[] for?

2015-11-24 Thread Antoon Pardon
Op 20-11-15 om 02:05 schreef Steven D'Aprano: > On Fri, 20 Nov 2015 04:30 am, BartC wrote: > >> On 19/11/2015 16:01, Steven D'Aprano wrote: > [...] > >> The whole concept of 'mutable' default is alien to me. A default is just >> a convenient device to avoid having to write: >> >>fn(0) or fn(

Re: What is a function parameter =[] for?

2015-11-24 Thread Ned Batchelder
On Tuesday, November 24, 2015 at 7:57:54 AM UTC-5, Marko Rauhamaa wrote: > Antoon Pardon : > > > You then switching to talking about objects, just gives the impression > > that object is a synonym for value. > > It isn't? We are tangled up in another terminology conflict. The word "value" is be

Re: What is a function parameter =[] for?

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 15:00 schreef Chris Angelico: > On Wed, Nov 25, 2015 at 12:43 AM, Antoon Pardon > wrote: >> I think that part of the problem is, that [] is not a constant object. So >> that when you see a line like >> >> ls = [] >> >> It behaves more lke >> >> ls = [].copy() >> >> than what

Re: Returning a result from 3 items in a list

2015-11-24 Thread Mark Lawrence
On 24/11/2015 14:07, Denis McMahon wrote: On Tue, 24 Nov 2015 02:04:56 -0800, Cai Gengyang wrote: Here's a dictionary with 3 values : results = { "gengyang": 14, "ensheng": 13, "jordan": 12 } How do I define a function that takes the last of the 3 items in that list and returns Jordan's

Re: What is a function parameter =[] for?

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 1:24 AM, Antoon Pardon wrote: >> Start thinking of it as a constructor call rather than a literal, and >> you'll get past most of the confusion. > > That doesn't change the fact it does look like a literal and not like > a constructor. Then explain how this is a literal:

Re: What is a function parameter =[] for?

2015-11-24 Thread Antoon Pardon
Op 20-11-15 om 13:12 schreef Ned Batchelder: > On Friday, November 20, 2015 at 6:59:54 AM UTC-5, BartC wrote: >> On 20/11/2015 01:05, Steven D'Aprano wrote: >>> On Fri, 20 Nov 2015 04:30 am, BartC wrote: >>> On 19/11/2015 16:01, Steven D'Aprano wrote: >>> [...] >>> The whole concept of 'm

Re: What is a function parameter =[] for?

2015-11-24 Thread Antoon Pardon
Op 20-11-15 om 14:04 schreef Chris Angelico: > On Fri, Nov 20, 2015 at 11:39 PM, BartC wrote: >> * The refusal to acknowledge that the def fn(a=[]) syntax is misleading. >> (What value will a have when you call fn()? The true answer is that you >> can't tell.) > > It isn't misleading. The default

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Arie van Wingerden
2015-11-24 14:41 GMT+01:00 Marko Rauhamaa : > Mark Lawrence : > > > 1) I was being facetious. > > 2) How many times do people have to be asked not to top post here > > before they stop top posting? > > 3) I only have two things to say so this is superfluous. > > Having posted only 2 times in this

Re: What is a function parameter =[] for?

2015-11-24 Thread BartC
On 24/11/2015 14:18, Ned Batchelder wrote: On Tuesday, November 24, 2015 at 7:57:54 AM UTC-5, Marko Rauhamaa wrote: Antoon Pardon : You then switching to talking about objects, just gives the impression that object is a synonym for value. It isn't? 1) In English, "value" means something l

<    1   2