readline and TAB-completion?

2015-11-24 Thread Ulli Horlacher
I need an input function with GNU readline support. So far I have: import readline readline.parse_and_bind("tab: complete") file = raw_input('File to send: ') Cursor keys are working, but TAB-completion works only in the current directory. Example: File to send: [TAB][TAB] argv.py

Re: Reading files from .ar / .deb archives

2015-11-24 Thread Ben Finney
Кисик Мурысик writes: > Hello! > I'm new to Python, so I decided to learn it Congratulations! Python is a fine language to learn, and this is the place to discuss general Python topics. You may also want to join the ‘tutor’ forum https://mail.python.org/mailman/listinfo/tutor>, which is specifi

Re: A name refers to an object, an object has a value, equality compares values

2015-11-24 Thread Marko Rauhamaa
Ben Finney : > Indeed, in the past I used the term “value” as synonymous (in Python > context) with the term “object”. I have become convinced through this > discussion that I should no longer use the terms that way. > > [...] > > The concepts are distinct, so I apologise for misleadingly conflati

Re: Istalling python

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 3:22 PM, ARONA KANAGARATHNA via Python-list wrote: > I tried to install this software python 3.4.3 to my pc which run windows Xp > 32. i could installed but it doesnot run.it gives this message > "python35-32/python.exe isnot a valid win32 app.Please help me to get solved

if else python

2015-11-24 Thread Scott Montreuil
Hi, I have an if statement which seems to run both commands and I cannot figure out why. (just learning so I may be missing something obvious) Any ideas? while True: global latit,longt,jlatit,jlongt,mlongt,mlatit response = urllib.urlopen(url) data = json.loads(response.r

Istalling python

2015-11-24 Thread ARONA KANAGARATHNA via Python-list
I tried to install this software python 3.4.3 to my pc which run windows Xp 32. i could installed but it doesnot run.it gives this message "python35-32/python.exe isnot a valid win32 app.Please help me to get solved this problem Thanks Aruna -- https://mail.python.org/mailman/listinfo/python-li

list slice and generators

2015-11-24 Thread Pavlos Parissis
Hi, Do you see any possible dangerous hidden bug in the below code(using python2.7 and python3.4)? My goal is to avoid go through the metrics list twice. But, I don't know if there will be a problem with doing in place replace of list elements using 2 generators. # metrics = ['', '0', '10']

Reading files from .ar / .deb archives

2015-11-24 Thread Кисик Мурысик
Hello! I'm new to Python, so I decided to learn it and write simple apt alternative (apt is somewhat broken for me). But I can't decide - can I read just one file (/DEBIAN/control) from archive without unpacking it, or do I need to unpack? And what module I can use to handle .ar files? (I read i

A name refers to an object, an object has a value, equality compares values (was: What is a function parameter =[] for?)

2015-11-24 Thread Ben Finney
Laura Creighton writes: > If I had a time machine, I would go back to early days of Python and > ban the use of the term 'assignment' and 'value' both. I would insist > that the term 'binding' be used instead, though if you want to use the > verb refer, to be synonymous with bind, well, I think t

ANN: released psutil 3.3.0 with OpenBSD support

2015-11-24 Thread Giampaolo Rodola'
Full story here: http://grodola.blogspot.com/2015/11/openbsd-support-for-psutil.html -- Giampaolo - http://grodola.blogspot.com -- https://mail.python.org/mailman/listinfo/python-list

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

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 11:36 AM, Steven D'Aprano wrote: > If, and only if, the tuple > contains nothing but immutable constants e.g. > > (1, 2.0, None, "spam") > > then a sufficiently smart compiler may be able to treat that specific tuple > as a constant/literal. But that's a special case, and c

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

2015-11-24 Thread Laura Creighton
In a message of Wed, 25 Nov 2015 11:39:54 +1100, "Steven D'Aprano" writes: >I'm not sure what value [ha, see what I did there?!] there is in inventing >two new words for things that we already have standard terms for. Done correctly, you can get clarity. >"Referent" is just a funny way of saying

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

2015-11-24 Thread Steven D'Aprano
On Wed, 25 Nov 2015 08:25 am, Antoon Pardon wrote: > The point is that a > tuple can just be loaded as a constant without needing something extra. How would one load this tuple as a constant? (myfile.read(), "%.5f" % sin(x or y)) The point is that *in general*, tuple so-called "literals" (wha

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

2015-11-24 Thread Steven D'Aprano
On Wed, 25 Nov 2015 01:18 am, Ned Batchelder wrote: > In English, "value" means something like, what is this equal to? > There isn't another good word to use in place of "value" here. There are many different meanings for the English noun "value" (Websters 1913 dictionary includes ten), but I th

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

2015-11-24 Thread Steven D'Aprano
On Wed, 25 Nov 2015 06:00 am, Random832 wrote: > On 2015-11-24, Chris Angelico wrote: >> Probably the grammar. In other words, it's part of the language's very >> definition. > > Then the definition is wrong. I think "literal" is a word whose meaning is > generally agreed on, rather than somethi

Re: Bi-directional sub-process communication

2015-11-24 Thread Cameron Simpson
On 24Nov2015 14:53, Ian Kelly wrote: On Mon, Nov 23, 2015 at 10:25 PM, Cameron Simpson wrote: Then #3. I would have a common function/method for submitting a request to go to the subprocess, and have that method return an Event on which to wait. Then caller then just waits for the Event and co

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

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 6:00 AM, Random832 wrote: > On 2015-11-24, Chris Angelico wrote: >> Probably the grammar. In other words, it's part of the language's very >> definition. > > Then the definition is wrong. I think "literal" is a word whose meaning is > generally agreed on, rather than somet

Re: import logging raise NotImplementedError

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 7:27 AM, wrote: > The problem happens with Python3 because "logging" is in the default > installation. In Python2 it is not installed. I installed it with >sudo python2 -m pip install logging -U > > This works without problems. Importing in Python2 works, too. You app

Re: Bi-directional sub-process communication

2015-11-24 Thread Ian Kelly
On Mon, Nov 23, 2015 at 10:25 PM, Cameron Simpson wrote: > Then #3. I would have a common function/method for submitting a request to > go to the subprocess, and have that method return an Event on which to wait. > Then caller then just waits for the Event and collects the data. Obviously, > the m

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

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 1:54 PM, Antoon Pardon wrote: > Op 24-11-15 om 20:15 schreef Ian Kelly: > >>> But no matter what you want to call it. The dis module shows that >>> -42 is treated in exactly the same way as 42, which is treated >>> exactly the same way as () or as (5, 8, 13) which is treate

Re: Bi-directional sub-process communication

2015-11-24 Thread Cameron Simpson
On 24Nov2015 06:33, israel wrote: On 11/23/2015 20:29, Cameron Simpson wrote: On 24Nov2015 16:25, Cameron Simpson wrote: Completely untested example code: class ReturnEvent: def __init__(self): self.event = Event() With, of course: def wait(self): return self.event.wait() Of c

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 22:14 schreef BartC: > On 24/11/2015 20:54, Antoon Pardon wrote: >> Op 24-11-15 om 20:15 schreef Ian Kelly: >> But no matter what you want to call it. The dis module shows that -42 is treated in exactly the same way as 42, which is treated exactly the same way as () or

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

2015-11-24 Thread BartC
On 24/11/2015 20:54, Antoon Pardon wrote: Op 24-11-15 om 20:15 schreef Ian Kelly: But no matter what you want to call it. The dis module shows that -42 is treated in exactly the same way as 42, which is treated exactly the same way as () or as (5, 8, 13) which is treated differently from [] or

import logging raise NotImplementedError

2015-11-24 Thread c.buhtz
I using 'logging' for some month. But today I have strange problem. When importing it it fails. Python 3.4.3 (default, Oct 14 2015, 20:33:09) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import logging Traceback (most recent call last): File "

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 20:15 schreef Ian Kelly: >> But no matter what you want to call it. The dis module shows that >> -42 is treated in exactly the same way as 42, which is treated >> exactly the same way as () or as (5, 8, 13) which is treated >> differently from [] or [5, 8, 13]. > > This is an imple

Re: Futex hang when running event loop on a separated thread

2015-11-24 Thread Marc Aymerich
On Tue, Nov 24, 2015 at 9:17 PM, Marc Aymerich wrote: > On Tue, Nov 24, 2015 at 8:41 PM, Zachary Ware > wrote: >> On Tue, Nov 24, 2015 at 12:37 PM, Marc Aymerich wrote: >>> still it appears to work only if the main thread is in the foreground >>> (as of calling Thread() with deamon=True), I don'

Re: Futex hang when running event loop on a separated thread

2015-11-24 Thread Marc Aymerich
On Tue, Nov 24, 2015 at 8:41 PM, Zachary Ware wrote: > On Tue, Nov 24, 2015 at 12:37 PM, Marc Aymerich wrote: >> still it appears to work only if the main thread is in the foreground >> (as of calling Thread() with deamon=True), I don't get why it behaves >> differently :( maybe it is waiting for

Re: Futex hang when running event loop on a separated thread

2015-11-24 Thread Zachary Ware
On Tue, Nov 24, 2015 at 12:37 PM, Marc Aymerich wrote: > still it appears to work only if the main thread is in the foreground > (as of calling Thread() with deamon=True), I don't get why it behaves > differently :( maybe it is waiting for other stuff, but no idea how to > confirm this with strace

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

2015-11-24 Thread Marko Rauhamaa
Steven D'Aprano : > On Wed, 25 Nov 2015 05:13 am, Marko Rauhamaa wrote: >> I would prefer this wording: >> >> Objects whose inner state can change are said to be mutable > > I see your point, but "inner state" might not be related to the > object's externally visible value. The inner state is in

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

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 12:00 PM, Random832 wrote: > On 2015-11-24, Chris Angelico wrote: >> Probably the grammar. In other words, it's part of the language's very >> definition. > > Then the definition is wrong. I think "literal" is a word whose meaning is > generally agreed on, rather than some

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

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 11:45 AM, Antoon Pardon wrote: > I think limiting literals to lexical tokens is too limited. Sure we > can define them like that in the context of the python grammar, but > I don't see why we should limit ourselves to such a definition outside > that context. > > I see noth

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

2015-11-24 Thread Random832
On 2015-11-24, Chris Angelico wrote: > Probably the grammar. In other words, it's part of the language's very > definition. Then the definition is wrong. I think "literal" is a word whose meaning is generally agreed on, rather than something each language's spec can invent from whole cloth for it

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

2015-11-24 Thread Ned Batchelder
On Tuesday, November 24, 2015 at 1:45:34 PM UTC-5, Antoon Pardon wrote: > Whether you want to call it literals or something else, the fact > remains that (3, 5, 8) is treated like -42 by the CPython interpreter > and [3, 5, 8] is not. Maybe I've lost the original point in all this minutia about wh

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 18:53 schreef Ian Kelly: > On Tue, Nov 24, 2015 at 10:32 AM, Antoon Pardon > wrote: >> Op 24-11-15 om 17:56 schreef Ian Kelly: >> >>> So on what grounds would you argue that () is not a literal. >>> >>> This enumerates exactly what literals are in Python: >>> >>> https://docs.p

Re: Futex hang when running event loop on a separated thread

2015-11-24 Thread Marc Aymerich
On Tue, Nov 24, 2015 at 7:11 PM, Zachary Ware wrote: > On Tue, Nov 24, 2015 at 9:46 AM, Marc Aymerich wrote: >> if __name__ == '__main__': >> loop_container = {} >> handler = threading.Thread(target=run_loop, args=(loop_container, )) >> handler.start() >> try: >> time.slee

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

2015-11-24 Thread Steven D'Aprano
On Wed, 25 Nov 2015 05:13 am, Marko Rauhamaa wrote: > Personally, I don't like the "official" Python usage: > > Objects whose value can change are said to be mutable > > I would prefer this wording: > > Objects whose inner state can change are said to be mutable I see your point, but "inner s

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 18:46 schreef Terry Reedy: > On 11/24/2015 9:34 AM, Antoon Pardon wrote: > > I agree that the tutorial should talk about default argument objects (which > have values) instead of conflating 'object' with 'value'. > >> Op 20-11-15 om 13:12 schreef Ned Batchelder: > >>> I'm not sur

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

2015-11-24 Thread Marko Rauhamaa
Ned Batchelder : > Oscar, thanks for the thoughtful comments. I agree that using "object" > for the result of an expression, and for the referent of a name, would > go some ways to clarifying things. > > Perhaps the Python world uses "value" less to mean "object" than I am > thinking. But we do ta

Re: Futex hang when running event loop on a separated thread

2015-11-24 Thread Zachary Ware
On Tue, Nov 24, 2015 at 9:46 AM, Marc Aymerich wrote: > if __name__ == '__main__': > loop_container = {} > handler = threading.Thread(target=run_loop, args=(loop_container, )) > handler.start() > try: > time.sleep(1) > finally: > loop_container['loop'].stop(

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

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 10:53 AM, Ian Kelly wrote: > On Tue, Nov 24, 2015 at 10:32 AM, Antoon Pardon > wrote: >> Op 24-11-15 om 17:56 schreef Ian Kelly: >> >>> So on what grounds would you argue that () is not a literal. >>> >>> This enumerates exactly what literals are in Python: >>> >>> ht

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

2015-11-24 Thread Steven D'Aprano
On Wed, 25 Nov 2015 01:58 am, Antoon Pardon wrote: > Op 23-11-15 om 14:58 schreef Steven D'Aprano: > > ... closures can also be used for [static storage] ... > If you really want mutable static storage, you can simulate it more > cleanly with a closure than using a default argument. You don't s

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

2015-11-24 Thread Steven D'Aprano
On Wed, 25 Nov 2015 02:17 am, Chris Angelico wrote: > On Wed, Nov 25, 2015 at 2:03 AM, Antoon Pardon > wrote: >> So are you saying >> >> () isn't a literal >> >> because >> >> (x * x for x in range(int(input("How far? " isn't a literal? > > I'm pretty sure tuple/list/dict display predat

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

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 10:32 AM, Antoon Pardon wrote: > Op 24-11-15 om 17:56 schreef Ian Kelly: > >> >>> So on what grounds would you argue that () is not a literal. >> >> This enumerates exactly what literals are in Python: >> >> https://docs.python.org/3/reference/lexical_analysis.html#literals

Re: Finding scores from a list

2015-11-24 Thread John Gordon
In <277843f7-c898-4378-85ea-841b09a28...@googlegroups.com> Cai Gengyang writes: > results = [ > {"id": 1, "name": "ensheng", "score": 10}, > {"id": 2, "name": "gengyang", "score": 12}, > {"id": 3, "name": "jordan", "score": 5}, > ] Okay, this is a list. > I want to find gengyang's score. This

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

2015-11-24 Thread Terry Reedy
On 11/24/2015 9:34 AM, Antoon Pardon wrote: I agree that the tutorial should talk about default argument objects (which have values) instead of conflating 'object' with 'value'. Op 20-11-15 om 13:12 schreef Ned Batchelder: I'm not sure what your goal is at this point. Are you: 1) stil

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

2015-11-24 Thread Ned Batchelder
On Tuesday, November 24, 2015 at 12:25:54 PM UTC-5, Oscar Benjamin wrote: > On 24 November 2015 at 15:27, Ned Batchelder wrote: > > On Tuesday, November 24, 2015 at 10:10:51 AM UTC-5, Antoon Pardon wrote: > >> Op 24-11-15 om 15:18 schreef Ned Batchelder: > >> > >> > 2) In Python, "value" means, wh

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 17:56 schreef Ian Kelly: > >> So on what grounds would you argue that () is not a literal. > > This enumerates exactly what literals are in Python: > > https://docs.python.org/3/reference/lexical_analysis.html#literals > > I think it's a rather pedantic point, though. How are nu

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

2015-11-24 Thread Steven D'Aprano
On Tue, 24 Nov 2015 11:38 pm, Antoon Pardon wrote: > Op 19-11-15 om 13:45 schreef Steven D'Aprano: [...] >> I don't mean that it isn't sometimes useful. Of course it is sometimes >> useful, there's no doubt about that. But why would you expect the >> language to default to the *slow*, *expensive*,

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

2015-11-24 Thread Oscar Benjamin
On 24 November 2015 at 15:27, Ned Batchelder wrote: > On Tuesday, November 24, 2015 at 10:10:51 AM UTC-5, Antoon Pardon wrote: >> Op 24-11-15 om 15:18 schreef Ned Batchelder: >> >> > 2) In Python, "value" means, what object does a name refer to, or what >> > object did an evaluation produce. >> >>

Re: Returning a result from 3 items in a list

2015-11-24 Thread Ned Batchelder
On Tuesday, November 24, 2015 at 9:29:30 AM UTC-5, Mark Lawrence wrote: > 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":

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

2015-11-24 Thread Ian Kelly
On Tue, Nov 24, 2015 at 9:41 AM, Antoon Pardon wrote: > Op 24-11-15 om 16:48 schreef Chris Angelico: >> () is not a literal either. > > The byte code sure suggests it is. > > Take the following code: > > import dis > > def f(): > i = 42 > t = () > l = [] > > dis.dis(f) > > That produces the

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 16:48 schreef Chris Angelico: > On Wed, Nov 25, 2015 at 2:46 AM, Antoon Pardon > wrote: >> What is your point? I say that [] looks like a literal. Because it >> sure resembles () which is a literal. >> >> That [] in fact isn't a literal doesn't contradict it looks like >> one. >> >>

Re: Futex hang when running event loop on a separated thread

2015-11-24 Thread Marc Aymerich
threading supports the 'daemon' option[1], when set to True and the program is in *foreground* then the event-loop thread dies when SIGTERM-ed, however, if the program is in the *background* it doesn't work! still deadlocked :'''( while I'm not finding a definitive solution I'll be doing a os.kill

Re: tuples in conditional assignment (Ben Finney)

2015-11-24 Thread George Trojan
Ben Finney writes: Ben Finney Date: 11/24/2015 04:49 AM To: python-list@python.org George Trojan writes: The following code has bitten me recently: t=(0,1) x,y=t if t else 8, 9 print(x, y) (0, 1) 9 You can simplify this by taking assignment out of the picture:: >>> t = (0, 1)

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

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 3:28 AM, Random832 wrote: > On 2015-11-24, Chris Angelico wrote: >> 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 t

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

2015-11-24 Thread Random832
On 2015-11-24, Chris Angelico wrote: > 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 const

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

2015-11-24 Thread Steven D'Aprano
On Tue, 24 Nov 2015 11:57 pm, 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? No it isn't. The definition of "object" -- well, I say "the" definition, but the nasty truth is

Re: Futex hang when running event loop on a separated thread

2015-11-24 Thread Marc Aymerich
On Tue, Nov 24, 2015 at 4:29 PM, Marc Aymerich wrote: > Hi, > > I have to run the asyncio.loop on a separated thread because the main > thread is running FUSE. Apparently fuse needs to run on the main > thread because it uses signal(): > > > File "/usr/local/lib/python3.4/dist-packages/fuse.p

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 16:17 schreef Chris Angelico: > On Wed, Nov 25, 2015 at 2:03 AM, Antoon Pardon > wrote: >> Op 24-11-15 om 15:34 schreef 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 > yo

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

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 2:46 AM, Antoon Pardon wrote: > What is your point? I say that [] looks like a literal. Because it > sure resembles () which is a literal. > > That [] in fact isn't a literal doesn't contradict it looks like > one. > > That you can come up with more complicated list express

Re: Bi-directional sub-process communication

2015-11-24 Thread israel
On 11/23/2015 20:29, Cameron Simpson wrote: On 24Nov2015 16:25, Cameron Simpson wrote: Completely untested example code: class ReturnEvent: def __init__(self): self.event = Event() With, of course: def wait(self): return self.event.wait() Of course :-) Ah, the Event() object

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

2015-11-24 Thread Ned Batchelder
On Tuesday, November 24, 2015 at 10:10:51 AM UTC-5, Antoon Pardon wrote: > Op 24-11-15 om 15:18 schreef Ned Batchelder: > > > 2) In Python, "value" means, what object does a name refer to, or what > > object did an evaluation produce. > > I don't think this is correct because that would imply tha

Futex hang when running event loop on a separated thread

2015-11-24 Thread Marc Aymerich
Hi, I have to run the asyncio.loop on a separated thread because the main thread is running FUSE. Apparently fuse needs to run on the main thread because it uses signal(): File "/usr/local/lib/python3.4/dist-packages/fuse.py", line 390, in __init__ old_handler = signal(SIGINT, SIG_DFL) V

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

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 2:03 AM, Antoon Pardon wrote: > Op 24-11-15 om 15:34 schreef 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 does

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 15:34 schreef 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 >>

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 15:18 schreef Ned Batchelder: > 2) In Python, "value" means, what object does a name refer to, or what > object did an evaluation produce. I don't think this is correct because that would imply that objects don't change values (since the value would be the object). When a list is

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 15:34 schreef 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 >>

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 15:34 schreef 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 >>

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

2015-11-24 Thread Antoon Pardon
Op 23-11-15 om 14:58 schreef Steven D'Aprano: > On Mon, 23 Nov 2015 09:40 pm, BartC wrote: > >> On 23/11/2015 07:47, Steven D'Aprano wrote: >> >>> I think it would be cleaner and better if Python had dedicated syntax for >>> declaring static local variables: >> >> Interesting. So why is it that wh

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

2015-11-24 Thread Chris Angelico
On Wed, Nov 25, 2015 at 1:43 AM, BartC wrote: > It comes from the use of file handles (what you get in some languages when > you open or create a file) which everyone can understand: > > * If you copy handle F to G like in an assignment, it obviously doesn't copy > the contents of the file, just t

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

2015-11-24 Thread Ned Batchelder
On Tuesday, November 24, 2015 at 9:34:36 AM UTC-5, Antoon Pardon wrote: > 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

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

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 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: 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 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: 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 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: 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 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: 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: 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: 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

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: 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

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 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 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: 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: What is a function parameter =[] for?

2015-11-24 Thread Antoon Pardon
Op 20-11-15 om 01:27 schreef Ned Batchelder: > On Thursday, November 19, 2015 at 7:11:52 PM UTC-5, BartC wrote: >> On 19/11/2015 22:55, Michael Torrie wrote: >>> On 11/19/2015 02:21 PM, BartC wrote: (Python returns 42; so that means my languages are more dynamic than Python? That's hard t

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Mark Lawrence
On 24/11/2015 12:23, Arie van Wingerden wrote: Hi Mark, what use would that have? Please show your code ... 2015-11-24 13:15 GMT+01:00 Mark Lawrence : On 24/11/2015 11:04, Cai Gengyang wrote: results = { "gengyang": { "maths": 10, "english": 15}, "ensheng": {"maths": 12, "english": 1

Finding scores from a list

2015-11-24 Thread Cai Gengyang
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 error message instead : Traceback (most r

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

2015-11-24 Thread Marko Rauhamaa
Antoon Pardon : > You then switching to talking about objects, just gives the impression > that object is a synonym for value. It isn't? Marko -- https://mail.python.org/mailman/listinfo/python-list

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

2015-11-24 Thread Antoon Pardon
Op 24-11-15 om 13:07 schreef Chris Angelico: > On Tue, Nov 24, 2015 at 10:36 PM, Antoon Pardon > wrote: So, looking at some source code, a default value for certain types is only certain to be that value for the very first call of that function? >>> >>> On the contrary, it is certain alw

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

2015-11-24 Thread Antoon Pardon
Op 19-11-15 om 13:45 schreef Steven D'Aprano: > On Thu, 19 Nov 2015 10:41 pm, BartC wrote: > > >> I expect the version with the default argument to be >> exactly the same as the last lot of calls, namely for: >> >> fn() >> fn() >> fn() >> >> to be equivalent to: >> >> temp=[] >> fn(temp) >> temp=

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Arie van Wingerden
Hi Mark, what use would that have? Please show your code ... 2015-11-24 13:15 GMT+01:00 Mark Lawrence : > On 24/11/2015 11:04, Cai Gengyang wrote: > >> results = { >>"gengyang": { "maths": 10, "english": 15}, >>"ensheng": {"maths": 12, "english": 10}, >>"jordan": {"maths": 9, "english

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Mark Lawrence
On 24/11/2015 11:04, 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 ? Thank you ... One way is to delete the scores for ensheng and

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

2015-11-24 Thread Chris Angelico
On Tue, Nov 24, 2015 at 10:36 PM, Antoon Pardon wrote: >>> So, looking at some source code, a default value for certain types is only >>> certain to be that value for the very first call of that function? >> >> On the contrary, it is certain always to be that exact object. > > No, he is talking ab

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Cai Gengyang
Great, it works! Thanks a lot .. >>> results = { "gengyang": { "maths": 10, "english": 15}, "ensheng": {"maths": 12, "english": 10}, "jordan": {"maths": 9, "english": 13} } >>> print((results["gengyang"])["maths"]) 10 On Tue, Nov 24, 2015 at 7:10 PM, Arie van Wingerden wrote: > print((

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Arie van Wingerden
print((results["gengyang"])["maths"]) 2015-11-24 12:04 GMT+01:00 Cai Gengyang : > results = { > "gengyang": { "maths": 10, "english": 15}, > "ensheng": {"maths": 12, "english": 10}, > "jordan": {"maths": 9, "english": 13} > } > > How do you get gengyang's maths scores ? > > Thank you ...

  1   2   >