Re: Question about math.pi is mutable

2015-11-10 Thread Steven D'Aprano
On Wednesday 11 November 2015 00:26, BartC wrote: > Does the Python language specify how it is to be compiled and executed? Not in so many words, but there are limitations on what you can do based on the specified semantics of Python. But so long as you meet those semantics, you can implement t

Re: Keeping context-manager object alive through function calls

2015-11-10 Thread Steven D'Aprano
On Wednesday 11 November 2015 09:36, Pablo Lucena wrote: > I am running into a bit of an issue with keeping a context manager open > through function calls. Here is what I mean: [...] > In order to keep the SSH session open and not have to re-establish it > across function calls, I would like to d

Re: using binary in python

2015-11-10 Thread Larry Hudson via Python-list
On 11/10/2015 12:14 PM, Dennis Lee Bieber wrote: On Mon, 9 Nov 2015 22:20:25 -0800, Larry Hudson via Python-list declaimed the following: Of course it can. The only difference a text file and a binary file is the way it's opened. Text files are opened with 'r' or 'w', while binary files are

Re: Question about math.pi is mutable

2015-11-10 Thread Steven D'Aprano
On Tue, 10 Nov 2015 11:14 pm, Ben Finney wrote: >> Python -- yes, even CPython -- has a runtime compiler. When you import >> a module, it is compiled (if needed) just before the import. Likewise, >> when you call the `compile`, `eval` or `exec` built-ins, the compiler >> operates. >> >> I'm not ca

Swig + Numpy.i with a const int16_t pointer

2015-11-10 Thread shriphanip
I am trying to wrap the following function with SWIG so I can call it from Python. The signature is: ``` int WebRtcVad_Process(VadInst* handle, int fs, const int16_t* audio_frame, size_t frame_length); ``` I have the following SWIG file: https://gist.github.com/shriphani/92c587ea4c32bafc9d97

Re: Using subprocess to capture a progress line

2015-11-10 Thread Tim Johnson
* Tim Johnson [151110 14:55]: > * Chris Angelico [151110 14:35]: > > On Wed, Nov 11, 2015 at 9:47 AM, Tim Johnson wrote: > > > I've written a command-line "wrapper" for youtube-dl, executing > > is implemented in Python, you might find it easier to "pip install > > youtube_dl" and work with the

Re: using binary in python

2015-11-10 Thread Michael Torrie
On 11/10/2015 02:29 PM, kent nyberg wrote: > On Mon, Nov 09, 2015 at 10:20:25PM -0800, Larry Hudson via Python-list wrote: >> Your questions are somewhat difficult to answer because you misunderstand >> binary. The key is that EVERYTHING in a computer is binary. There are NO >> EXCEPTIONS, it's a

Re: Using subprocess to capture a progress line

2015-11-10 Thread Tim Johnson
* Tim Johnson [151110 14:55]: > * Chris Angelico [151110 14:35]: > > On Wed, Nov 11, 2015 at 9:47 AM, Tim Johnson wrote: > > > I've written a command-line "wrapper" for youtube-dl, executing > > > youtube-dl as a subprocess. > > > > > > ---

Re: using binary in python

2015-11-10 Thread Random832
Dennis Lee Bieber writes: > Given that a dram is 1/8 of a "fluid ounce" that leads to the > conclusion that a "wee dram" is based on US standard fluid once, 29.6 ml > vs British standard fluid ounce... 28.4 ml It's our _pints_ that are smaller than yours, not our ounces. -- https://mai

Re: using binary in python

2015-11-10 Thread Random832
Dennis Lee Bieber writes: > > Given that a dram is 1/8 of a "fluid ounce" that leads to the > conclusion that a "wee dram" is based on US standard fluid once, 29.6 ml > vs British standard fluid ounce... 28.4 ml It's our _pints_ that are smaller than yours, not our ounces. -- https://m

Re: Using subprocess to capture a progress line

2015-11-10 Thread Tim Johnson
* Chris Angelico [151110 14:35]: > On Wed, Nov 11, 2015 at 9:47 AM, Tim Johnson wrote: > > I've written a command-line "wrapper" for youtube-dl, executing > > youtube-dl as a subprocess. > > > > -- > > youtube-dl reports download pro

Re: Using subprocess to capture a progress line

2015-11-10 Thread Chris Angelico
On Wed, Nov 11, 2015 at 9:47 AM, Tim Johnson wrote: > I've written a command-line "wrapper" for youtube-dl, executing > youtube-dl as a subprocess. > > -- > youtube-dl reports download progress on one line. I.E. the line is > overwrit

Re: bitwise operator, bits dont go into bitbucket..?

2015-11-10 Thread Chris Angelico
On Wed, Nov 11, 2015 at 9:56 AM, kent nyberg wrote: > So, to check if 0b010[this one bit]010 is set, i do & 0b0001000 > > That is, I set just that one to 1 in the other and then the & operator will > make it return > 0 if its not set. Since every other is zero, the return will be zero if its

Re: bitwise operator, bits dont go into bitbucket..?

2015-11-10 Thread kent nyberg
On Wed, Nov 11, 2015 at 09:33:38AM +1100, Chris Angelico wrote: > On Wed, Nov 11, 2015 at 9:27 AM, kent nyberg wrote: > > If you want to check specific bits (in C or Python, either way), it's > much more common to use bitwise AND than bit shifts: > > >>> 0b100011011101010110 & 0b0001 >

Using subprocess to capture a progress line

2015-11-10 Thread Tim Johnson
Using python 2.7.6 on ubuntu 14.04 The application in question is run with bash and gnome-terminal : I've written a command-line "wrapper" for youtube-dl, executing youtube-dl as a subprocess. -- youtube-dl reports download progress

Re: Keeping context-manager object alive through function calls

2015-11-10 Thread Chris Angelico
On Wed, Nov 11, 2015 at 9:36 AM, Pablo Lucena wrote: > And calling it as such: > > def do_more_stuff(device): > gen = do_stuff(device, return_handle=True) > data, conn = next(gen) > output = conn.send_command("show users") > #process output... > return processed_output The fir

Re: Keeping context-manager object alive through function calls

2015-11-10 Thread Ben Finney
Pablo Lucena writes: > In order to keep the SSH session open and not have to re-establish it > across function calls, I would like to do add an argument to > "do_stuff" which can optionally return the SSH session along with the > data returned from the SSH session, as follows: > > def do_stuff(de

Keeping context-manager object alive through function calls

2015-11-10 Thread Pablo Lucena
I am running into a bit of an issue with keeping a context manager open through function calls. Here is what I mean: There is a context-manager defined in a module which I use to open SSH connections to network devices. The "setup" code handles opening the SSH sessions and handling any issues, and

Re: bitwise operator, bits dont go into bitbucket..?

2015-11-10 Thread Chris Angelico
On Wed, Nov 11, 2015 at 9:27 AM, kent nyberg wrote: > Im reading about bitwise operators and is it true to say they dont work 100% > as in C? > bitwise operators in C seem to result in bits going to the so called > bitbucket. > For example, 0b0001. Shifting it >> 1 in C it seems to add on z

bitwise operator, bits dont go into bitbucket..?

2015-11-10 Thread kent nyberg
Im reading about bitwise operators and is it true to say they dont work 100% as in C? bitwise operators in C seem to result in bits going to the so called bitbucket. For example, 0b0001. Shifting it >> 1 in C it seems to add on zero to the left and the 1 to the right gets throwned away. Bu

OT: Re: using binary in python

2015-11-10 Thread mm0fmf via Python-list
On 10/11/2015 21:02, Dennis Lee Bieber wrote: On Tue, 10 Nov 2015 20:36:52 +, mm0fmf via Python-list declaimed the following: On 10/11/2015 20:14, Dennis Lee Bieber wrote: The Ada language defines the end of Text file to consist of It is 15 years this month since I last worked in place

Re: using binary in python

2015-11-10 Thread kent nyberg
On Mon, Nov 09, 2015 at 10:20:25PM -0800, Larry Hudson via Python-list wrote: > Your questions are somewhat difficult to answer because you misunderstand > binary. The key is that EVERYTHING in a computer is binary. There are NO > EXCEPTIONS, it's all binary ALL the time. The difference comes ab

Re: using binary in python

2015-11-10 Thread Mark Lawrence
On 10/11/2015 20:36, mm0fmf via Python-list wrote: On 10/11/2015 20:14, Dennis Lee Bieber wrote: The Ada language defines the end of Text file to consist of It is 15 years this month since I last worked in place that used Ada. I think that calls for a wee dram to celebrate ;-) Followed by a

Re: using binary in python

2015-11-10 Thread Random832
Dennis Lee Bieber writes: > To be strict -- a text file has system defined means of marking > line endings. UNIX/Linux uses just a character; Windows uses the pair > . TRS-DOS used just for end of line. Some operating systems > may have used count-delimited formats (and then there is the

Re: using binary in python

2015-11-10 Thread mm0fmf via Python-list
On 10/11/2015 20:14, Dennis Lee Bieber wrote: The Ada language defines the end of Text file to consist of It is 15 years this month since I last worked in place that used Ada. I think that calls for a wee dram to celebrate ;-) -- https://mail.python.org/mailman/listinfo/python-list

Re: IDLE quits unexpectedly when about to open or creat a new file

2015-11-10 Thread Terry Reedy
On 11/10/2015 6:01 AM, Chris Angelico wrote: On Tue, Nov 10, 2015 at 9:46 PM, wrote: I need help to find out what's going on. I did some research, but I couldn't find anything to solve this problem: - I open the IDLE program; From the Start menu icon, let us presume. - I go to the 'File'

Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > > I have a problem with it: There is no feedback for the user about the > > progress of the transfer, which can last several hours. > > > > For small files shutil.copyfileobj() is a good idea, but not for huge > > ones. > > Indeed. Have a look at the sourc

Re: corrupt download with urllib2

2015-11-10 Thread Peter Otten
Ulli Horlacher wrote: > Ulli Horlacher wrote: >> Peter Otten <__pete...@web.de> wrote: > >> > - consider shutil.copyfileobj to limit memory usage when dealing with >> > data >> > of arbitrary size. >> > >> > Putting it together: >> > >> > with open(sz, "wb") as szo: >> > shutil.c

Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Ulli Horlacher wrote: > Peter Otten <__pete...@web.de> wrote: > > - consider shutil.copyfileobj to limit memory usage when dealing with data > > of arbitrary size. > > > > Putting it together: > > > > with open(sz, "wb") as szo: > > shutil.copyfileobj(u, szo) > > This writes the

RE: python PEP suggestion

2015-11-10 Thread Dan Strohl
You mentioned that it is a bit contrary to how Python currently works, I am not sure I understand that, can you elaborate a bit? "Conditional execution, indexing (__index__), numeric conversions (__float__ also), and displaying are special cases related to syntax operations. You have left out

Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > Ulli Horlacher wrote: > > > if u.getcode() == 200: > > print(u.read(),file=szo,end='') > > szo.close() > > else: > > die('cannot get %s - server reply: %d' % (szurl,u.getcode())) > > More random remarks: Always welcome - I am here

Re: corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
Peter Otten <__pete...@web.de> wrote: > > It works with Linux, but not with Windows 7, where the downloaded 7za.exe > > is corrupt: it has the wrong size, 589044 instead of 587776 Bytes. > > > > Where is my error? > > > sz = path.join(fexhome,'7za.exe') > > szurl = "http://fex.belwue.de

Re: corrupt download with urllib2

2015-11-10 Thread Peter Otten
Ulli Horlacher wrote: > if u.getcode() == 200: > print(u.read(),file=szo,end='') > szo.close() > else: > die('cannot get %s - server reply: %d' % (szurl,u.getcode())) More random remarks: - print() gives the impression that you are dealing with text, and using it with

Re: Question about math.pi is mutable

2015-11-10 Thread BartC
On 10/11/2015 11:34, Steven D'Aprano wrote: On Tue, 10 Nov 2015 05:10 pm, Ben Finney wrote: I am a Bear of Little Brain, but: Isn't anything that the *compiler* does, by definition done at *compile* time? In a manner of speaking, yes, of course. But you've missed the critical issue: when is

Re: corrupt download with urllib2

2015-11-10 Thread Peter Otten
Ulli Horlacher wrote: > I am currently developing a program which should run on Linux and Windows. > Later it shall be compiled with PyInstaller. Therefore I am using Python > 2.7 > > My program must download http://fex.belwue.de/download/7za.exe > > I am using this code: > It works with Linux,

corrupt download with urllib2

2015-11-10 Thread Ulli Horlacher
I am currently developing a program which should run on Linux and Windows. Later it shall be compiled with PyInstaller. Therefore I am using Python 2.7 My program must download http://fex.belwue.de/download/7za.exe I am using this code: sz = path.join(fexhome,'7za.exe') szurl = "http://f

Re: help in pexpect multiprocessing

2015-11-10 Thread Pablo Lucena
I think the problem is that you cannot pass around an open socket via pickle. Whats the error message you are getting? Try adding the session establishment code to the stop function, so that each new process opens a session to the server and executes the command. def stop(ds): s = pxssh.p

Re: help in pexpect multiprocessing

2015-11-10 Thread harirammanohar159
On Monday, 9 November 2015 18:07:36 UTC+5:30, hariramm...@gmail.com wrote: > Hi, > > I am using multiprocessing with pexpect, issue is whenever i call a function > which is having expect(), its throwing error which is genuine as multiple > threads are processing it same time (i/o prompt same ti

Re: Extracting and summing student scores from a JSON file using Python 2.7.10

2015-11-10 Thread Bernie Lazlo
On Monday, 9 November 2015 18:53:06 UTC-5, Bernie Lazlo wrote: > This should be a simple problem but I have wasted hours on it. Any help would > be appreciated. [I have taken my code back to almost the very beginning.] > > The student scores need to be summed. > =

Re: Extracting and summing student scores from a JSON file using Python 2.7.10

2015-11-10 Thread Bernie Lazlo
On Monday, 9 November 2015 22:54:05 UTC-5, wayne@gmail.com wrote: > On Monday, 9 November 2015 22:27:40 UTC-5, Denis McMahon wrote: > > On Mon, 09 Nov 2015 15:52:45 -0800, Bernie Lazlo wrote: > > > > > This should be a simple problem but I have wasted hours on it. Any help > > > would be app

Re: Question about math.pi is mutable

2015-11-10 Thread Ben Finney
Laura Creighton writes: > In a message of Tue, 10 Nov 2015 17:10:09 +1100, Ben Finney writes: > >I am a Bear of Little Brain, but: Isn't anything that the *compiler* > >does, by definition done at *compile* time? > > No. > > We used to have a pretty strict defintion about what a compiler was, > a

Re: Question about math.pi is mutable

2015-11-10 Thread Steven D'Aprano
On Tue, 10 Nov 2015 05:10 pm, Ben Finney wrote: > Steven D'Aprano writes: > >> Ben, I fear that you are not paying attention to me :-) > > Possibly, though I also think there's miscommunication in this thread. > > You speak of “compile time” and “run time”. You also speak of what the > compile

Re: IDLE quits unexpectedly when about to open or creat a new file

2015-11-10 Thread Chris Angelico
On Tue, Nov 10, 2015 at 9:46 PM, wrote: > I need help to find out what's going on. I did some research, but I couldn't > find anything to solve this problem: > > - I open the IDLE program; > - I go to the 'File' menu; > - I select the 'New File' option > - IDLE quits. > > I run the IDLE version

IDLE quits unexpectedly when about to open or creat a new file

2015-11-10 Thread trindadegoncalves
Hello, I need help to find out what's going on. I did some research, but I couldn't find anything to solve this problem: - I open the IDLE program; - I go to the 'File' menu; - I select the 'New File' option - IDLE quits. I run the IDLE version 3.3.3 on Windows 8.1 Pro. Should I install the mos

Re: Getting response by email reply message

2015-11-10 Thread Laura Creighton
In a message of Tue, 10 Nov 2015 11:23:21 +0100, Laura Creighton writes: >Their is no demand for 'yes/no answers' -- you can typically vote for s/Their/There/ ... >the whole thing way, way, way to heavy-weight for most purposes. s/to/too/ also s/heavy-weight/heavyweight/ depending on where in t

Re: Question about math.pi is mutable

2015-11-10 Thread Laura Creighton
In a message of Tue, 10 Nov 2015 17:10:09 +1100, Ben Finney writes: >Steven D'Aprano writes: > >> Ben, I fear that you are not paying attention to me :-) > >Possibly, though I also think there's miscommunication in this thread. > >You speak of “compile time” and “run time”. You also speak of what

Re: Getting response by email reply message

2015-11-10 Thread Laura Creighton
In a message of Mon, 09 Nov 2015 23:09:50 -0800, zljubi...@gmail.com writes: >> If what you really need is a voting application, you can look at >> https://github.com/mdipierro/evote which the PSF uses for its elections. > >It is not a voting application (I will have more than yes/no answers). >I

Re: help in pexpect multiprocessing

2015-11-10 Thread harirammanohar159
On Monday, 9 November 2015 18:07:36 UTC+5:30, hariramm...@gmail.com wrote: > Hi, > > I am using multiprocessing with pexpect, issue is whenever i call a function > which is having expect(), its throwing error which is genuine as multiple > threads are processing it same time (i/o prompt same ti

Re: Question about math.pi is mutable

2015-11-10 Thread Antoon Pardon
Op 10-11-15 om 00:29 schreef Ben Finney: > > Who is doing what to whom? The user of the library isn't doing anything > to the library author, so what is it the library author would consent > to? Instead, you seem to be trying to assert a *power* of the library > author to restrict the library user.

Re: Extracting and summing student scores from a JSON file using Python 2.7.10

2015-11-10 Thread Pete Dowdell
On 10/11/15 08:12, Bernie Lazlo wrote: > > import json > >import urllib > >url ="http://www.wickson.net/geography_assignment.json"; > >response = urllib.urlopen(url) > >data = json.loads(response.read()) All good up to data. Now: # make a list of scores scores = [d['score'] for d in data['comme

Re: Question about math.pi is mutable

2015-11-10 Thread Terry Reedy
On 11/9/2015 9:37 PM, Steven D'Aprano wrote: The compiler doesn't need to decide *in advance* whether the attribute might have changed. It knows whether it has changed or not *at runtime*. You are using 'compiler' when you should, to avoid confusion, use 'interpreter'. It's one thing to sa

Re: Calulation in lim (1 + 1 /n) ^n when n -> infinite

2015-11-10 Thread Salvatore DI DIO
Thank you very much Peter -- https://mail.python.org/mailman/listinfo/python-list