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

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

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

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

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

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

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']

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

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

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

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

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: [argparse] optional parameter without --switch

2015-11-24 Thread Peter Otten
c.bu...@posteo.jp wrote: > I want to call (on bash) a Python script in this two ways without any > error. > > ./arg.py > ./arg.py TEST > > It means that the parameter (here with the value `TEST`) should be > optional. With argparse I only know a way to create optional paramters > when th

Re: Problem to read from array

2015-11-24 Thread Crane Ugly
It is nothing more but naming convention. This code was part of the function. Actually, in the final version I removed that "f" and changed some names of variables to shorter versions. It is all about your own preferences towards readability of the code and ability of visual capture of the code.

Persistent api-ms-win-crt-runtime-i1-1-0.dll start up error

2015-11-24 Thread Tolga . Karabiyikoglu
Hi all; Yesterday just downloaded python-3.5.0-amd64 on windows10 running laptop- running flawless. But my trouble is with my office desktop Windows Vista. Considering the processor diference, this time, downloaded the python-3.5.0 (32 bit) version. The question is i am receiving 'api-ms-win

Re: Problem to read from array

2015-11-24 Thread Peter Otten
Crane Ugly wrote: > I always try to have code that easy to read. That's laudable, code is a means of communication. > At least for myself. and only for yourself, unfortunately. Recommended read: https://www.python.org/dev/peps/pep-0008/ -- https://mail.python.org/mailman/listinfo/python-l

Re: Persistent api-ms-win-crt-runtime-i1-1-0.dll start up error

2015-11-24 Thread Laura Creighton
In a message of Tue, 24 Nov 2015 10:56:32 +0200, tolga.karabiyiko...@ankara.edu .tr writes: >Hi all; > >Yesterday just downloaded python-3.5.0-amd64 on windows10 running >laptop- running flawless. > >But my trouble is with my office desktop Windows Vista. Considering the >processor diference, thi

Returning a result from 3 items in a list

2015-11-24 Thread Cai Gengyang
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) ? Thanks a lot ! Gengyang -- https://mail.python.org/mailman/listinfo/python-l

Re: Returning a result from 3 items in a list

2015-11-24 Thread Chris Angelico
On Tue, Nov 24, 2015 at 9:04 PM, 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) ? > > Than

Re: Returning a result from 3 items in a list

2015-11-24 Thread Cai Gengyang
Strange, it gives me an error message when i type result["jordan"] or result[max(result)] though : >>> results = { "gengyang": 14, "ensheng": 13, "jordan": 12 } >>> result["jordan"] Traceback (most recent call last): File "", line 1, in result["jordan"] NameError: name 'result'

Re: Returning a result from 3 items in a list

2015-11-24 Thread Peter Otten
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) ? > > Thanks a lot ! You can access the

Re: Returning a result from 3 items in a list

2015-11-24 Thread Peter Otten
Cai Gengyang wrote: > Strange, it gives me an error message when i type result["jordan"] or > result[max(result)] though : > results = { > "gengyang": 14, > "ensheng": 13, > "jordan": 12 > } > result["jordan"] > Traceback (most recent call last): > File "", line 1, in > re

Re: Returning a result from 3 items in a list

2015-11-24 Thread Cai Gengyang
Yup, thanks a lot ... it works now ! >>> results = { "gengyang": 14, "ensheng": 13, "jordan": 12 } >>> results["jordan"] 12 On Tuesday, November 24, 2015 at 6:40:26 PM UTC+8, Peter Otten wrote: > Cai Gengyang wrote: > > > Strange, it gives me an error message when i type result["jordan"

Re: Persistent api-ms-win-crt-runtime-i1-1-0.dll start up error

2015-11-24 Thread eryksun
On Tue, Nov 24, 2015 at 3:54 AM, Laura Creighton wrote: > In a message of Tue, 24 Nov 2015 10:56:32 +0200, > tolga.karabiyiko...@ankara.edu > >>The question is i am receiving 'api-ms-win-crt-runtime-i1-1-0.dll is >>missing' error on the start up. > > You appear to have this problem. > > https://b

Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread 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 ... -- https://mail.python.org/mailman/listinfo/python-list

Re: Returning a result from 3 items in a list

2015-11-24 Thread Chris Angelico
On Tue, Nov 24, 2015 at 9:35 PM, Peter Otten <__pete...@web.de> wrote: > Yeah, the error message really should be > > "NameError: name 'result' is not defined; did you mean 'results'?" > > ;) Heh. Yes, that was my fault. Sorry Cai! it should have been results["jordan"], as you figured out. ChrisA

Re: Returning a result from 3 items in a list

2015-11-24 Thread Cai Gengyang
Its cool ... No problem On Tuesday, November 24, 2015 at 7:05:25 PM UTC+8, Chris Angelico wrote: > On Tue, Nov 24, 2015 at 9:35 PM, Peter Otten <__pete...@web.de> wrote: > > Yeah, the error message really should be > > > > "NameError: name 'result' is not defined; did you mean 'results'?" > > > >

Re: tuples in conditional assignment

2015-11-24 Thread Steven D'Aprano
On Tue, 24 Nov 2015 02:25 pm, George Trojan wrote: > The following code has bitten me recently: > > >>> t=(0,1) > >>> x,y=t if t else 8, 9 > >>> print(x, y) > (0, 1) 9 > > I was assuming that a comma has the highest order of evaluation, that is > the expression 8, 9 should make a tuple. Why t

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Steven D'Aprano
On Tue, 24 Nov 2015 10:04 pm, 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 ? Break the problem into two steps: - get Gengya

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

2015-11-24 Thread Antoon Pardon
Op 19-11-15 om 00:22 schreef Chris Angelico: > On Thu, Nov 19, 2015 at 10:14 AM, BartC wrote: >> On 18/11/2015 22:11, Ian Kelly wrote: >>> >>> On Wed, Nov 18, 2015 at 2:08 PM, fl wrote: Hi, I have tried the below function and find that it can remember the previous se

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

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

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

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

  1   2   >