python response slow when running external DLL

2015-11-26 Thread jfong
I am new to Python. As an exercise of it, I try to port a program which was written more than 10 years ago. This program use the Borland C++ Builder as its GUI front end and a DLL does the real work(it will takes a few seconds to complete). I saw a strange phenomenon in the following codes. The

Re: Py_NewInterpreter() - Fatal Error with ceval - orphan tstate

2015-11-26 Thread dieter
"ramjee a.g." writes: > I am using python 2.7 for extending my C++ application with python. > > And when two pthread of C is executing Py_NewInterpreter() it is throwing > faltal error with ceval-orphan tstate. There is no problem when sequential > thread execution. "tstate" likely stands for "

Re: Help needed with compiling python

2015-11-26 Thread Kev Dwyer
Cecil Westerhof wrote: > On Thursday 26 Nov 2015 09:29 CET, Steven D'Aprano wrote: > >> On Thursday 26 November 2015 18:00, Cecil Westerhof wrote: >> >>> On Wednesday 25 Nov 2015 23:58 CET, Laura Creighton wrote: >>> In a message of Wed, 25 Nov 2015 22:52:23 +0100, Cecil Westerhof write

Re: Help needed with compiling python

2015-11-26 Thread Zachary Ware
On Thu, Nov 26, 2015 at 3:39 PM, Cecil Westerhof wrote: > On Thursday 26 Nov 2015 12:07 CET, Dave Farrance wrote: >> zypper in -f >> >> So you'll want to try package names like "python" and "python2.7". > > Sadly that also only installs only libraries and no applications. Try "python-base". (Se

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

2015-11-26 Thread Ben Finney
Steven D'Aprano writes: > On Fri, 27 Nov 2015 12:40 pm, Ben Finney wrote: > > > It's still not been expressed what “fake” refers to here. Or, rather, > > what “real” thing was being expected, and how these don't qualify. > > They are faked in the sense that in this implementation, the object > li

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

2015-11-26 Thread Random832
Steven D'Aprano writes: > On Thu, 26 Nov 2015 09:34 pm, Dave Farrance wrote: > > >> (Conversely, I see that unlike CPython, all PyPy's numbers have >> unchanging ids, even after exiting PyPy and restarting, so it seems that >> PyPy's numerical ids are "faked".) >> >> [PyPy 2.6.1 with GCC 4.9.2]

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

2015-11-26 Thread Chris Angelico
On Fri, Nov 27, 2015 at 1:56 PM, MRAB wrote: > You could argue that it _does_ continue to exist, it just changes its > form... PyPy: The Quantum Mechanics of Python programming. If you aren't actually looking at something right at this instant, it might exist in a different form... or not exist a

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

2015-11-26 Thread MRAB
On 2015-11-27 02:44, Steven D'Aprano wrote: On Fri, 27 Nov 2015 12:40 pm, Ben Finney wrote: Steven D'Aprano writes: On Thu, 26 Nov 2015 09:34 pm, Dave Farrance wrote: > (Conversely, I see that unlike CPython, all PyPy's numbers have > unchanging ids, even after exiting PyPy and restarting,

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

2015-11-26 Thread Steven D'Aprano
On Fri, 27 Nov 2015 12:40 pm, Ben Finney wrote: > Steven D'Aprano writes: > >> On Thu, 26 Nov 2015 09:34 pm, Dave Farrance wrote: >> >> >> > (Conversely, I see that unlike CPython, all PyPy's numbers have >> > unchanging ids, even after exiting PyPy and restarting, so it seems >> > that PyPy's n

Re: Object identity has no necessary connection to memory location

2015-11-26 Thread Steven D'Aprano
On Fri, 27 Nov 2015 07:00 am, Ben Finney wrote: > Dave Farrance writes: > >> >> >Dave Farrance : >> >> > >> >> >> (Conversely, I see that unlike CPython, all PyPy's numbers have >> >> >> unchanging ids, even after exiting PyPy and restarting, so it seems >> >> >> that PyPy's numerical ids are "f

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
On 27/11/2015 01:46, Steven D'Aprano wrote: On Thu, 26 Nov 2015 12:52 pm, Ned Batchelder wrote: For someone who claims to be interested in language design, you're remarkably dismissive of pretty much the entire industry. I don't think it's worth the effort to try to change your mind. In fair

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Steven D'Aprano
On Thu, 26 Nov 2015 12:52 pm, Ned Batchelder wrote: > For someone who claims to be interested in language design, you're > remarkably dismissive of pretty much the entire industry. I don't think > it's worth the effort to try to change your mind. In fairness to BartC, I don't think that's malici

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Steven D'Aprano
On Thu, 26 Nov 2015 10:23 pm, Marko Rauhamaa wrote: > Chris Angelico : > >> On Thu, Nov 26, 2015 at 9:54 PM, Marko Rauhamaa wrote: >>> >>>>>> hash([]) >>>Traceback (most recent call last): >>> File "", line 1, in >>>TypeError: unhashable type: 'list' >>> >>> Annoying. >> >> Yes

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

2015-11-26 Thread Ben Finney
Steven D'Aprano writes: > On Thu, 26 Nov 2015 09:34 pm, Dave Farrance wrote: > > > > (Conversely, I see that unlike CPython, all PyPy's numbers have > > unchanging ids, even after exiting PyPy and restarting, so it seems > > that PyPy's numerical ids are "faked".) > > I'm pretty sure that they ar

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

2015-11-26 Thread Steven D'Aprano
On Thu, 26 Nov 2015 09:34 pm, Dave Farrance wrote: > (Conversely, I see that unlike CPython, all PyPy's numbers have > unchanging ids, even after exiting PyPy and restarting, so it seems that > PyPy's numerical ids are "faked".) > > [PyPy 2.6.1 with GCC 4.9.2] on linux2 > id(1+2j) > 67990011

Re: Question about output different with command dis.dis(code)

2015-11-26 Thread Steven D'Aprano
On Thu, 26 Nov 2015 08:02 pm, fl wrote: > Hi, > > I see the following from a previous post: > > > Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat > 4.1.2-52)] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam import dis code = compile("(1

Re: reading from a txt file

2015-11-26 Thread Pedro Vincenty
All were really helpful thanks a lot. Now I'm interested in identifying a particular index after being able to print out each word. Printing each word to the console I have : ['METEOSAT-7'] ['1', '24932U', '97049B', '15319.57839525', '.0058', '0-0', '0+0', '0', '9994'] ['2', '249

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Steven D'Aprano
On Thu, 26 Nov 2015 07:27 pm, Marko Rauhamaa wrote: > What I'm saying is that Python does not prevent mutable keys but tries > to do that with lists and tuples. > > I think Python should stop trying. > > I have wanted to use lists as keys, and there should be no reason to > allow mutable tuples.

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread MRAB
On 2015-11-27 00:15, Random832 wrote: Chris Angelico writes: Windows: I'm not sure, and frankly, I don't trust it. A quick test showed a couple of failures: It might be case insensitive only for ASCII. Windows uses a simple WCHAR->WCHAR (lower->upper) mapping for case comparison. it doesn't

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Steven D'Aprano
On Thu, 26 Nov 2015 12:23 pm, BartC wrote: > On 26/11/2015 00:31, Steven D'Aprano wrote: >> In 2015, it's hard to think of any non-obsolete, non-toy language which >> doesn't treat functions as first-class values, including creating them on >> the fly. Fortran and C perhaps. > > It's funny then

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Fri, Nov 27, 2015 at 11:15 AM, Random832 wrote: > Chris Angelico writes: >> Windows: I'm not sure, and frankly, I don't trust it. A quick test >> showed a couple of failures: >> >> It might be case insensitive only for ASCII. > > Windows uses a simple WCHAR->WCHAR (lower->upper) mapping for ca

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Random832
Chris Angelico writes: > Windows: I'm not sure, and frankly, I don't trust it. A quick test > showed a couple of failures: > > It might be case insensitive only for ASCII. Windows uses a simple WCHAR->WCHAR (lower->upper) mapping for case comparison. it doesn't handle those cases, but it does ha

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Fri, Nov 27, 2015 at 9:27 AM, BartC wrote: > On 26/11/2015 13:15, Chris Angelico wrote: >> >> On Thu, Nov 26, 2015 at 11:53 PM, BartC wrote: > > >>> http://pastebin.com/JrVTher6 > > >> #14 and #15: Are you assuming that a character is a byte and that >> diacritical-free English is the only lan

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
On 26/11/2015 13:15, Chris Angelico wrote: On Thu, Nov 26, 2015 at 11:53 PM, BartC wrote: http://pastebin.com/JrVTher6 #14 and #15: Are you assuming that a character is a byte and that diacritical-free English is the only language in the world? I don't think that need be the assumption.

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Gregory Ewing
BartC wrote: I simply stated that Python's approach was novel. Steven D'Aprano then responded by belittling my view, and effectively trashing every language I've ever used. He pointed out that many other dynamic languages construct functions on the fly the same way that Python does, going all

Re: Help needed with compiling python

2015-11-26 Thread Cecil Westerhof
On Thursday 26 Nov 2015 12:07 CET, Dave Farrance wrote: > Cecil Westerhof wrote: > >> On Wednesday 25 Nov 2015 23:58 CET, Laura Creighton wrote: >>> >>> Your Suse system probably wants to use python for something. If >>> your system python is damaged, you badly need to fix that, using >>> the sys

Re: Help needed with compiling python

2015-11-26 Thread Cecil Westerhof
On Thursday 26 Nov 2015 09:29 CET, Steven D'Aprano wrote: > On Thursday 26 November 2015 18:00, Cecil Westerhof wrote: > >> On Wednesday 25 Nov 2015 23:58 CET, Laura Creighton wrote: >> >>> In a message of Wed, 25 Nov 2015 22:52:23 +0100, Cecil Westerhof >>> writes: My system python was

Re: Object identity has no necessary connection to memory location

2015-11-26 Thread Mark Lawrence
On 26/11/2015 20:00, Ben Finney wrote: Dave Farrance writes: Dave Farrance : (Conversely, I see that unlike CPython, all PyPy's numbers have unchanging ids, even after exiting PyPy and restarting, so it seems that PyPy's numerical ids are "faked".) Hence https://en.wikipedia.org/wiki/Scar

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: >> What I'm saying is that Python does not prevent mutable keys but >> tries to do that with lists and tuples. >> >> I think Python should stop trying. > > Do you volunteer to answer all the posts from beginners complaining > that "the dict type is broken" b

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Gregory Ewing
Marko Rauhamaa wrote: What I'm saying is that Python does not prevent mutable keys but tries to do that with lists and tuples. I think Python should stop trying. Do you volunteer to answer all the posts from beginners complaining that "the dict type is broken" because they used a list as a key

Re: reading from a txt file

2015-11-26 Thread Gary Herron
On 11/26/2015 12:34 PM, vincentype...@gmail.com wrote: Hey, I'm wondering how to read individual strings in a text file. I can read a text file by lines with .readlines() , but I need to read specifically by strings, not including spaces. Thanks in advance Read the lines with readlines(), a

Re: reading from a txt file

2015-11-26 Thread Jason Friedman
> > Hey, I'm wondering how to read individual strings in a text file. I can > read a text file by lines with .readlines() , > but I need to read specifically by strings, not including spaces. Thanks > in advance > How about: for a_string in open("/path/to/file").read().split(): print(a_stri

Re: reading from a txt file

2015-11-26 Thread Denis McMahon
On Thu, 26 Nov 2015 12:34:36 -0800, vincentypedro wrote: > Hey, I'm wondering how to read individual strings in a text file. I can > read a text file by lines with .readlines() , > but I need to read specifically by strings, not including spaces. > Thanks in advance How do you define a string?

reading from a txt file

2015-11-26 Thread vincentypedro
Hey, I'm wondering how to read individual strings in a text file. I can read a text file by lines with .readlines() , but I need to read specifically by strings, not including spaces. Thanks in advance -- https://mail.python.org/mailman/listinfo/python-list

Re: Object identity has no necessary connection to memory location

2015-11-26 Thread Ben Finney
Dave Farrance writes: > >> >Dave Farrance : > >> > > >> >> (Conversely, I see that unlike CPython, all PyPy's numbers have > >> >> unchanging ids, even after exiting PyPy and restarting, so it seems > >> >> that PyPy's numerical ids are "faked".) > > Hence > > https://en.wikipedia.org/wiki/Scare_

Re: What does a list comprehension do

2015-11-26 Thread Antoon Pardon
Op 26-11-15 om 16:36 schreef Marko Rauhamaa: > Antoon Pardon : > >> [ for in ] >> >> would implicitly be rewritten as follows: >> >> [ (lambda : )() for in ] > > Funny enough, that's how "list comprehensions" are created in Scheme: > >(map (lambda (i) > (lambda (x) (* i

Re: read 4D binary data

2015-11-26 Thread Laura Creighton
In a message of Thu, 26 Nov 2015 15:15:43 -0200, jorge.conr...@cptec.inpe.br wr ites: >Hi, > > >I'm startig in Python and I have a 4D binary data. The dimension of my >data is: > >67 > longitude points >41 > latitude points >10 > pressure levels points >33 > time points > > >How ca

Re: read 4D binary data

2015-11-26 Thread Denis McMahon
On Thu, 26 Nov 2015 15:15:43 -0200, jorge.conrado wrote: > I'm startig in Python and I have a 4D binary data. The dimension of my > data is: > > 67 > longitude points 41 > latitude points 10 > pressure > levels points 33 > time points > > How can I read this data and what can I d

Re: read 4D binary data

2015-11-26 Thread Mark Lawrence
On 26/11/2015 17:15, jorge.conr...@cptec.inpe.br wrote: Hi, I'm startig in Python and I have a 4D binary data. The dimension of my data is: 67 > longitude points 41 > latitude points 10 > pressure levels points 33 > time points How can I read this data and what can I do to ge

read 4D binary data

2015-11-26 Thread jorge . conrado
Hi, I'm startig in Python and I have a 4D binary data. The dimension of my data is: 67 > longitude points 41 > latitude points 10 > pressure levels points 33 > time points How can I read this data and what can I do to get a 2D array (longitude,latitude) for a specific press

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread MRAB
On 2015-11-26 12:53, BartC wrote: On 26/11/2015 01:52, Ned Batchelder wrote: On Wednesday, November 25, 2015 at 8:23:36 PM UTC-5, BartC wrote: On 26/11/2015 00:31, Steven D'Aprano wrote: It really, truly isn't. Your viewpoint is clouded by too much immersion in crippled languages. *Old and o

Re: What does a list comprehension do

2015-11-26 Thread Jussi Piitulainen
Antoon Pardon writes: > Op 26-11-15 om 14:56 schreef Marko Rauhamaa: >> Antoon Pardon wrote: >> >>> I don't understand. What I propose would be a minor change in how >>> list comprehension works. I don't see how your example can be turned >>> into a list comprehension. >> >> The list comprehension

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread MRAB
On 2015-11-26 14:40, BartC wrote: On 26/11/2015 13:15, Chris Angelico wrote: On Thu, Nov 26, 2015 at 11:53 PM, BartC wrote: FWIW here is that list of features that are different between Python and my language, or that work a different way, or that I think could be a useful addition. (Although

Re: ANN: tornadostreamform

2015-11-26 Thread Nagy László Zsolt
> PyPi: https://pypi.python.org/pypi/tornadostreamform > Documentation: https://pypi.python.org/pypi/tornadostreamform Wrong paste. Here is the good one: https://pythonhosted.org/tornadostreamform/ -- https://mail.python.org/mailman/listinfo/python-list

ANN: tornadostreamform

2015-11-26 Thread Nagy László Zsolt
Pure python module that let’s you upload *huge* files to a tornado web server. This project provides the |tornadostreamform.multipart_streamer.MultiPartStreamer| class that incrementally parses incoming multipart/form-data, splits it into form fields, and streams the fields into file like objects

Re: What does a list comprehension do

2015-11-26 Thread Marko Rauhamaa
Antoon Pardon : > [ for in ] > > would implicitly be rewritten as follows: > > [ (lambda : )() for in ] Funny enough, that's how "list comprehensions" are created in Scheme: (map (lambda (i) (lambda (x) (* i x))) '(0 1 2 3 > There would no change on how lamb

Re: Python on windows 10

2015-11-26 Thread Terry Reedy
On 11/25/2015 3:34 PM, francis funari wrote: I have tried installing Python 3 on windows 10 it install OK but I do not get Idle. When I type Idle in the interpreter nothing happen Starting programs by typing their names into the interactive interpreter does not work. Use Start Menu | All App

Re: Python on windows 10

2015-11-26 Thread Laura Creighton
In a message of Wed, 25 Nov 2015 20:34:01 +, francis funari writes: >I have tried installing Python 3 on windows 10 it install OK but I do not get >Idle. When I type Idle in the interpreter nothing happen can you send me a >link to latest release of Python 3 with Idle that will run on windows

Re: Screen scraper to get all 'a title' elements

2015-11-26 Thread Denis McMahon
On Wed, 25 Nov 2015 12:42:00 -0800, ryguy7272 wrote: > Hello experts. I'm looking at this url: > https://en.wikipedia.org/wiki/Wikipedia:Unusual_place_names > > I'm trying to figure out how to list all 'a title' elements. a is the element tag, title is an attribute of the htmlanchorelement. co

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
On 26/11/2015 13:15, Chris Angelico wrote: On Thu, Nov 26, 2015 at 11:53 PM, BartC wrote: FWIW here is that list of features that are different between Python and my language, or that work a different way, or that I think could be a useful addition. (Although Python's internal workings make man

Re: What does a list comprehension do

2015-11-26 Thread Antoon Pardon
Op 26-11-15 om 14:56 schreef Marko Rauhamaa: > Antoon Pardon : > >> I don't understand. What I propose would be a minor change in >> how list comprehension works. I don't see how your example >> can be turned into a list comprehension. > The list comprehension is only a special case of the interact

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 11:53 PM, BartC wrote: > FWIW here is that list of features that are different between Python and my > language, or that work a different way, or that I think could be a useful > addition. (Although Python's internal workings make many impractical.) > > http://pastebin.com/

Re: What does a list comprehension do

2015-11-26 Thread Marko Rauhamaa
Antoon Pardon : > I don't understand. What I propose would be a minor change in > how list comprehension works. I don't see how your example > can be turned into a list comprehension. The list comprehension is only a special case of the interaction between closures and variables. If you dabble wi

Re: Looking for ideas to improve library API

2015-11-26 Thread Chris Lalancette
On Thu, Nov 26, 2015 at 7:46 AM, Devin Jeanpierre wrote: > Why not take ownership of the file object, instead of requiring users > to manage lifetimes? Yeah, I've kind of been coming to this conclusion. So my question then becomes: how do I "take ownership" of it? I already keep a reference to

Re: What does a list comprehension do

2015-11-26 Thread Antoon Pardon
Op 26-11-15 om 13:56 schreef Marko Rauhamaa: > Antoon Pardon : > >> Personnaly I would prefer: >> > q = [(lambda i: lambda x: i * x)(i) for i in range(4)] > q[0](1), q[3](1) >> (0, 3) >> >> And this is where I ask whether it would be worth the effort to change >> the behaviour of python. >

Re: Looking for ideas to improve library API

2015-11-26 Thread Chris Lalancette
On Thu, Nov 26, 2015 at 7:36 AM, MRAB wrote: > Why pass a file descriptor? Why not a filename? The reason for a file descriptor is so that I can also add other file-like objects, such as StringIO. My unit tests, for instance, rely heavily on this. That being said, it is not *strictly* required

Re: if else python

2015-11-26 Thread John Gordon
In Scott Montreuil writes: > I have an if statement which seems to run both commands and I cannot > figure out why. I'm not sure what you mean by "both commands". Do you mean that the 'if' and 'else' branches both execute? Your if/else branches are in a loop, so perhaps you're seeing the 'if

Re: What does a list comprehension do

2015-11-26 Thread Marko Rauhamaa
Antoon Pardon : > Personnaly I would prefer: > q = [(lambda i: lambda x: i * x)(i) for i in range(4)] q[0](1), q[3](1) > (0, 3) > > And this is where I ask whether it would be worth the effort to change > the behaviour of python. Don't go there. Consider: q = [] n = 0 x =

fexit: file transfer of ANY size

2015-11-26 Thread Ulli Horlacher
In the last weeks I have asked here some beginners questions and got great response. I was able to solve all my problems. Now, my first real Python program is ready: fexit, a F*EX client. And what is F*EX? ==> Frams' Fast File EXchange, a service for transfering files of ANY size from any user A

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread BartC
On 26/11/2015 01:52, Ned Batchelder wrote: On Wednesday, November 25, 2015 at 8:23:36 PM UTC-5, BartC wrote: On 26/11/2015 00:31, Steven D'Aprano wrote: It really, truly isn't. Your viewpoint is clouded by too much immersion in crippled languages. *Old and obsolete versions* of crippled langu

Re: Looking for ideas to improve library API

2015-11-26 Thread Devin Jeanpierre
Why not take ownership of the file object, instead of requiring users to manage lifetimes? -- Devin On Wed, Nov 25, 2015 at 12:52 PM, Chris Lalancette wrote: > Hello, > I'm currently developing a library called pyiso ( > https://github.com/clalancette/pyiso), used for manipulating ISO disk

Re: Looking for ideas to improve library API

2015-11-26 Thread MRAB
On 2015-11-25 20:52, Chris Lalancette wrote: Hello, I'm currently developing a library called pyiso ( https://github.com/clalancette/pyiso), used for manipulating ISO disk images. I'm pretty far along with it, but there is one part of the API that I really don't like. Typical usage of

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Nov 26, 2015 at 10:23 PM, Marko Rauhamaa wrote: >> It's not letting me in the case of list. > > Actually it is. Your mistake is trying to use a list as a dict key. > You have a solution available: use a tuple. Yes, or wrap the list in a class. Marko -- https://mail.

Re: Object identity has no necessary connection to memory location

2015-11-26 Thread Antoon Pardon
Op 26-11-15 om 12:49 schreef Chris Angelico: > I can't remember which language it was (maybe Lua?), but I know > there's one that uses a machine word to store either a pointer to a > heap object, or an integer of at most one less bit than the machine > word, represented by 2*n+1. I think that was

Re: Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 10:24 PM, Ben Finney wrote: > Dave Farrance writes: > >> Marko Rauhamaa wrote: >> >> >Dave Farrance : >> > >> >> (Conversely, I see that unlike CPython, all PyPy's numbers have >> >> unchanging ids, even after exiting PyPy and restarting, so it seems >> >> that PyPy's num

Re: Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?)

2015-11-26 Thread Dave Farrance
Ben Finney wrote: >Dave Farrance writes: > >> Marko Rauhamaa wrote: >> >> >Dave Farrance : >> > >> >> (Conversely, I see that unlike CPython, all PyPy's numbers have >> >> unchanging ids, even after exiting PyPy and restarting, so it seems >> >> that PyPy's numerical ids are "faked".) >> > >> >

Re: What does a list comprehension do

2015-11-26 Thread Antoon Pardon
Op 26-11-15 om 12:13 schreef Nobody: > Returning to the original expression: > > > q = [lambda x: i * x for i in range(4)] > > q[0](1), q[3](1) > (3, 3) > > q = [lambda x,i=i: i * x for i in range(4)] > > q[0](1), q[3](1) > (0, 3) Personnaly I would prefer: >>>

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 10:23 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Thu, Nov 26, 2015 at 9:54 PM, Marko Rauhamaa wrote: >>> >>>>>> hash([]) >>>Traceback (most recent call last): >>> File "", line 1, in >>>TypeError: unhashable type: 'list' >>> >>> Annoying. >> >>

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

2015-11-26 Thread Marko Rauhamaa
Dave Farrance : > Marko Rauhamaa wrote: >>What's a faked id? > > You can figure out what I'm getting at -- i.e. I presume that the ids > are not pointers to stored numbers in memory (as with CPython) but are > a translation of the numerical variable's value. CPython is within its rights to fake

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

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 10:12 PM, Dave Farrance wrote: > Marko Rauhamaa wrote: > >>Dave Farrance : >> >>> (Conversely, I see that unlike CPython, all PyPy's numbers have >>> unchanging ids, even after exiting PyPy and restarting, so it seems >>> that PyPy's numerical ids are "faked".) >> >>What's

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Nov 26, 2015 at 9:54 PM, Marko Rauhamaa wrote: >> >>>>> hash([]) >>Traceback (most recent call last): >> File "", line 1, in >>TypeError: unhashable type: 'list' >> >> Annoying. > > Yes, it's really annoying that you get an immediate exception instead

Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?)

2015-11-26 Thread Ben Finney
Dave Farrance writes: > Marko Rauhamaa wrote: > > >Dave Farrance : > > > >> (Conversely, I see that unlike CPython, all PyPy's numbers have > >> unchanging ids, even after exiting PyPy and restarting, so it seems > >> that PyPy's numerical ids are "faked".) > > > >What's a faked id? > > You can

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Mark Lawrence
On 26/11/2015 06:52, Marko Rauhamaa wrote: Steven D'Aprano : Making tuples mutable would break their use as dictionary keys, which is a *critical* use. No, it wouldn't. Any object that provides __hash__() and __eq__() can be used as a key. Almost, see https://wiki.python.org/moin/Dictionar

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

2015-11-26 Thread Dave Farrance
Marko Rauhamaa wrote: >Dave Farrance : > >> (Conversely, I see that unlike CPython, all PyPy's numbers have >> unchanging ids, even after exiting PyPy and restarting, so it seems >> that PyPy's numerical ids are "faked".) > >What's a faked id? You can figure out what I'm getting at -- i.e. I pre

Re: What does a list comprehension do (was: Late-binding of function defaults (was Re: What is a function parameter =[] for?))

2015-11-26 Thread Nobody
On Wed, 25 Nov 2015 14:51:23 +0100, Antoon Pardon wrote: > Am I missing something? The issue is with lambdas rather than with list comprehensions per se. Python's lambdas capture free variables by reference, not value. > x = 3 > f = lambda y: x + y > f(0) 3

Re: Help needed with compiling python

2015-11-26 Thread Dave Farrance
Cecil Westerhof wrote: >On Wednesday 25 Nov 2015 23:58 CET, Laura Creighton wrote: >> >> Your Suse system probably wants to use python for something. If your >> system python is damaged, you badly need to fix that, using the >> system package managers tools, before Suse does some sort of update >

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 9:54 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Thu, Nov 26, 2015 at 7:27 PM, Marko Rauhamaa wrote: >>> I have wanted to use lists as keys, and there should be no reason to >>> allow mutable tuples. It should be enough to say that the behavior of >>> a dictionary

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

2015-11-26 Thread Marko Rauhamaa
Dave Farrance : > (Conversely, I see that unlike CPython, all PyPy's numbers have > unchanging ids, even after exiting PyPy and restarting, so it seems > that PyPy's numerical ids are "faked".) What's a faked id? Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Nov 26, 2015 at 7:27 PM, Marko Rauhamaa wrote: >> I have wanted to use lists as keys, and there should be no reason to >> allow mutable tuples. It should be enough to say that the behavior of >> a dictionary is undefined if a key should mutate on the fly. > > Python def

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

2015-11-26 Thread Dave Farrance
Alan Bawden wrote: >Chris Angelico writes: > ... >> Python 2.7.8 (2.4.0+dfsg-3, Dec 20 2014, 13:30:46) >> [PyPy 2.4.0 with GCC 4.9.2] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> tuple([]) is tuple([]) >> False > >I said I wouldn't be suprised if it

Re: Question about output different with command dis.dis(code)

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 8:02 PM, fl wrote: > Are there something, my input or Python difference > make the output different? Anything involving the disassembly of Python code depends heavily on internal interpreter details. You just quoted something showing that ancient versions of Python did at

Re: Question about output different with command dis.dis(code)

2015-11-26 Thread Random832
fl writes: > Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat > 4.1.2-52)] on linux2 The context of the post was discussing the behavior of a very old version of python. I'm not sure how you missed this. > When I run the above three line code, I get the following: Further

Question about output different with command dis.dis(code)

2015-11-26 Thread fl
Hi, I see the following from a previous post: Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import dis >>> code = compile("(1, 2, 3)", "", "eval") >>> dis.dis(code) 0 S

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Antoon Pardon
Op 26-11-15 om 09:27 schreef Marko Rauhamaa: > Chris Angelico : > >> On Thu, Nov 26, 2015 at 5:52 PM, Marko Rauhamaa wrote: >>> Nothing prevents using mutable objects as keys in Python. >> Sure, you _can_. But if the key's hash changes between dict insertion >> and retrieval, all manner of invaria

Py_NewInterpreter() - Fatal Error with ceval - orphan tstate

2015-11-26 Thread ramjee a.g.
Hi, I am using python 2.7 for extending my C++ application with python. And when two pthread of C is executing Py_NewInterpreter() it is throwing faltal error with ceval-orphan tstate. There is no problem when sequential thread execution. Let me know if any solution to be fixed in my python lib

Python on windows 10

2015-11-26 Thread francis funari
I have tried installing Python 3 on windows 10 it install OK but I do not get Idle. When I type Idle in the interpreter nothing happen can you send me a link to latest release of Python 3 with Idle that will run on windows 10 64 bit

Looking for ideas to improve library API

2015-11-26 Thread Chris Lalancette
Hello, I'm currently developing a library called pyiso ( https://github.com/clalancette/pyiso), used for manipulating ISO disk images. I'm pretty far along with it, but there is one part of the API that I really don't like. Typical usage of the library is something like: import pyiso p

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 7:27 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Thu, Nov 26, 2015 at 5:52 PM, Marko Rauhamaa wrote: >>> Nothing prevents using mutable objects as keys in Python. >> >> Sure, you _can_. But if the key's hash changes between dict insertion >> and retrieval, all man

Re: Help needed with compiling python

2015-11-26 Thread Steven D'Aprano
On Thursday 26 November 2015 18:00, Cecil Westerhof wrote: > On Wednesday 25 Nov 2015 23:58 CET, Laura Creighton wrote: > >> In a message of Wed, 25 Nov 2015 22:52:23 +0100, Cecil Westerhof >> writes: >>> >>> My system python was all-ready damaged: that is why I wanted to >>> build myself. >> >>

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Antoon Pardon
Op 26-11-15 om 02:52 schreef Ned Batchelder: > I almost started to explain about how yes, Python is often written in > conservative static ways. I was going to mention that a little dynamic > nature goes a long way, and is never far from the surface in even the > simplest Python programs. > > But I

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Marko Rauhamaa
Chris Angelico : > On Thu, Nov 26, 2015 at 5:52 PM, Marko Rauhamaa wrote: >> Nothing prevents using mutable objects as keys in Python. > > Sure, you _can_. But if the key's hash changes between dict insertion > and retrieval, all manner of invariants will break, and likewise if > two equal object

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

2015-11-26 Thread Antoon Pardon
Op 25-11-15 om 23:38 schreef Ian Kelly: > On Wed, Nov 25, 2015 at 2:05 PM, Antoon Pardon > wrote: >> Op 25-11-15 om 21:39 schreef Ian Kelly: >> >>> I believe that sentence from the docs is using "some" to mean "not >>> all", whereas you are apparently using it to mean "any". >>> >>> frozenset([1,2

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-26 Thread Chris Angelico
On Thu, Nov 26, 2015 at 5:52 PM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Making tuples mutable would break their use as dictionary keys, which is a >> *critical* use. > > No, it wouldn't. Any object that provides __hash__() and __eq__() can be > used as a key. > > Nothing prevents using mut