Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Wed, 2 Sep 2015 02:20 am, Marko Rauhamaa wrote: >> Steven D'Aprano: >> >>> I believe that Marko is wrong. It is not so easy to compile Python >>> to machine language for real machines. That's why the compiler >>> targets a virtual machine instead. >> >> Somehow Guile

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Marko Rauhamaa
Steven D'Aprano : > On Wed, 2 Sep 2015 02:20 am, Marko Rauhamaa wrote: >> I never said a compiler would translate Python to (analogous) machine >> language. I said you could easily turn CPython into a dynamic library >> (run-time environment) and write a small bootstrapper that you >> package into

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Michael Torrie
On 08/31/2015 02:35 AM, Mahan Marwat wrote: > What I know about an interpreter and a compiler is: they both convert > source code to machine code and the only difference is, an > interpreter convert it, line by line while compiler convert the whole > source file. Now if we compile a C source file o

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Steven D'Aprano
On Wed, 2 Sep 2015 02:20 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> I believe that Marko is wrong. It is not so easy to compile Python to >> machine language for real machines. That's why the compiler targets a >> virtual machine instead. > > Somehow Guile manages it even though Scheme i

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Cameron Simpson
On 02Sep2015 08:01, Cameron Simpson wrote: One circumstance where you might use fdopen and _not_ want .close to close the underlying service is when you're handed a file descriptor over which you're supposed to perform some I/O, and the I/O library functions use high level files. In that case

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Chris Angelico
On Wed, Sep 2, 2015 at 6:08 AM, Marko Rauhamaa wrote: > Laura Creighton : > >> But are Guile programs small? > > They can be tiny because libguile-2.0.so, the interpreter, is a dynamic > library and is installed on the computer. It's barely different from how > compiled C programs can be a few kil

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Grant Edwards
On 2015-09-01, Laura Creighton wrote: > Don't go around closing things you don't know are open. They > could be some other processes' thing. I don't understand. Closing a file descriptor that isn't open is harmless, isn't it? Closing one that _is_ open only affects the current process. If ot

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Cameron Simpson
On 01Sep2015 11:56, random...@fastmail.us wrote: On Tue, Sep 1, 2015, at 10:57, Steven D'Aprano wrote: Q3: I could probably answer Q2 myself if I knew how to check whether a fd was open or not. With a file object, I can inspect file_obj.closed and it will tell me whether the file is open or no

Re: netcdf read

2015-09-01 Thread Jason Swails
On Tue, Sep 1, 2015 at 2:07 PM, Chris Angelico wrote: > On Wed, Sep 2, 2015 at 3:23 AM, wrote: > > I'm starting in the Python scripts. I run this script: > > > > > > import numpy as np > > > > import netCDF4 > > > > f = netCDF4.Dataset('uwnd.mon.ltm.nc','r') > > > > > > f.variables > > > > > >

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Marko Rauhamaa
Laura Creighton : > But are Guile programs small? They can be tiny because libguile-2.0.so, the interpreter, is a dynamic library and is installed on the computer. It's barely different from how compiled C programs can be a few kilobytes in size because libc.so is dynamic. Emacs is a lisp interp

Re: netcdf read

2015-09-01 Thread Chris Angelico
On Wed, Sep 2, 2015 at 3:23 AM, wrote: > I'm starting in the Python scripts. I run this script: > > > import numpy as np > > import netCDF4 > > f = netCDF4.Dataset('uwnd.mon.ltm.nc','r') > > > f.variables > > > and I had the message: > > > netcdf4.py > Traceback (most recent call last): > File

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Laura Creighton
>But are Guile programs small? I the OP made a categorisation error, >confusing correlation with causation. (i.e. the presence of >feathers makes a animal able to fly). s/I the/I think the/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Laura Creighton
In a message of Wed, 02 Sep 2015 00:57:22 +1000, "Steven D'Aprano" writes: >Let's suppose somebody passes me a file descriptor to work with. It could >come from somewhere else, but for the sake of discussion let's pretend I >create it myself this way: >Q1: In this example, I know that I opened th

netcdf read

2015-09-01 Thread jorge . conrado
Hi, I'm starting in the Python scripts. I run this script: import numpy as np import netCDF4 f = netCDF4.Dataset('uwnd.mon.ltm.nc','r') f.variables and I had the message: netcdf4.py Traceback (most recent call last): File "", line 1, in NameError: name 'netcdf4' is not defined Wh

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Laura Creighton
In a message of Tue, 01 Sep 2015 19:20:51 +0300, Marko Rauhamaa writes: >Somehow Guile manages it even though Scheme is at least as dynamic a >language as Python. But are Guile programs small? I the OP made a categorisation error, confusing correlation with causation. (i.e. the presence of feath

Re: How to compare lists

2015-09-01 Thread Rustom Mody
On Tuesday, September 1, 2015 at 12:54:08 PM UTC+5:30, Jahn wrote: > 1. > How can I save 256 lists, each list has 32 values( hexadecimal numbers) > 2. > How to compare the saved lists with another 256 lists ( that are read online > and have the > same structure as the list one)? > ( the first lis

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Ian Kelly
On Mon, Aug 31, 2015 at 11:45 PM, Luca Menegotto wrote: > Il 31/08/2015 19:48, Mahan Marwat ha scritto: > >> If it hasn't been considered all that useful, then why > >> the tools like cx_freeze, pytoexe are doing very hard! > > Well, I consider those tools useless at all! > I appreciate Python bec

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread eric
On Tue, Sep 1, 2015 at 12:20 PM, Marko Rauhamaa wrote: Steven D'Aprano : I believe that Marko is wrong. It is not so easy to compile Python to machine language for real machines. That's why the compiler targets a virtual machine instead. Somehow Guile manages it even though Scheme is

Re: Does mkstemp open files only if they don't already exist?

2015-09-01 Thread Laura Creighton
In a message of Wed, 02 Sep 2015 00:57:45 +1000, Chris Angelico writes: >On Wed, Sep 2, 2015 at 12:45 AM, Steven D'Aprano wrote: >> I assume the answer is "Yes", but is it safe to expect that >> tempfile.mkstemp() will only create a file that doesn't already exist? I >> presume that there's no cha

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Chris Angelico
On Wed, Sep 2, 2015 at 2:20 AM, Marko Rauhamaa wrote: > In fact, the shebang notation turns any single .py file into such an > executable. The problem is if you break your program into modules. Java, > of course, solved a similar problem with .jar files (but still wouldn't > jump over the final hu

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Marko Rauhamaa
Steven D'Aprano : > I believe that Marko is wrong. It is not so easy to compile Python to > machine language for real machines. That's why the compiler targets a > virtual machine instead. Somehow Guile manages it even though Scheme is at least as dynamic a language as Python. I never said a com

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread random832
On Tue, Sep 1, 2015, at 10:57, Steven D'Aprano wrote: > Q1: In this example, I know that I opened the fd in write mode, because > I > did it myself. But since I'm not actually opening it, how do I know what > mode to use in the call to fdopen? Is there something I can call to find > out what mode

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Steven D'Aprano
On Tue, 1 Sep 2015 03:48 am, Mahan Marwat wrote: >> Python programs *could* easily be compiled the same way, but it generally >> hasn't been considered all that useful. > > If it hasn't been considered all that useful, then why the tools like > cx_freeze, pytoexe are doing very hard! And if it is

Low level file descriptors and high-level Python files

2015-09-01 Thread Steven D'Aprano
Let's suppose somebody passes me a file descriptor to work with. It could come from somewhere else, but for the sake of discussion let's pretend I create it myself this way: import os fd = os.open("some path", "w") I then turn it into a file object: file_obj = os.fdopen(fd, mode) Q1: In this

Re: Does mkstemp open files only if they don't already exist?

2015-09-01 Thread Chris Angelico
On Wed, Sep 2, 2015 at 12:45 AM, Steven D'Aprano wrote: > I assume the answer is "Yes", but is it safe to expect that > tempfile.mkstemp() will only create a file that doesn't already exist? I > presume that there's no chance of it over-writing an existing file (say, > due to a race-condition). I

Does mkstemp open files only if they don't already exist?

2015-09-01 Thread Steven D'Aprano
I assume the answer is "Yes", but is it safe to expect that tempfile.mkstemp() will only create a file that doesn't already exist? I presume that there's no chance of it over-writing an existing file (say, due to a race-condition). -- Steven -- https://mail.python.org/mailman/listinfo/python-l

Re: execute commands as su on remote server

2015-09-01 Thread Laura Creighton
In a message of Tue, 01 Sep 2015 05:16:48 -0700, harirammanohar...@gmail.com wr ites: >On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com wrote: >> execute commands as su on remote server >> >> Postby hariram » Mon Aug 17, 2015 4:02 am >> Needed: >> I need to execute commands aft

Re: execute commands as su on remote server

2015-09-01 Thread harirammanohar159
On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com wrote: > execute commands as su on remote server > > Postby hariram » Mon Aug 17, 2015 4:02 am > Needed: > I need to execute commands after doing su to other user on remote server(not > sudo which doesn't require password) how i

Re: How to compare lists

2015-09-01 Thread Denis McMahon
On Tue, 01 Sep 2015 07:08:48 +0200, Jahn wrote: > 1. > How can I save 256 lists, each list has 32 values( hexadecimal numbers) > 2. > How to compare the saved lists with another 256 lists ( that are read > online and have the same structure as the list one)? > ( the first list must be saved in the

Re: How to compare lists

2015-09-01 Thread Laura Creighton
In a message of Tue, 01 Sep 2015 07:08:48 +0200, "Jahn" writes: >1. >How can I save 256 lists, each list has 32 values( hexadecimal numbers) >2. >How to compare the saved lists with another 256 lists ( that are read online >and have the >same structure as the list one)? >( the first list must be

Re: How to compare lists

2015-09-01 Thread jmp
On 09/01/2015 07:08 AM, Jahn wrote: 1. How can I save 256 lists, each list has 32 values( hexadecimal numbers) 2. How to compare the saved lists with another 256 lists ( that are read online and have the same structure as the list one)? ( the first list must be saved in the previous step) E.

Re: RPI.GPIO Help

2015-09-01 Thread Johannes Bauer
On 31.08.2015 19:41, John McKenzie wrote: > Still checking here and am discussing all this in the Raspberry pi > newsgroup. Thanks to the several people who mentioned it. > > Again, still listening here if anyone has any more to add. I've had the problem to use interrupt-driven GPIOs on the P

Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Laura Creighton
If I understand what you are saying, then I think what you are looking for is not a compiler, but docker. see: https://www.docker.com/ in particular https://www.docker.com/whatisdocker PyPy used this to produce portable PyPy binaries. See: https://github.com/squeaky-pl/portable-pypy/blob/master/R

Re: How to compare lists

2015-09-01 Thread Peter Otten
Jahn wrote: > 1. > How can I save 256 lists, each list has 32 values( hexadecimal numbers) > 2. > How to compare the saved lists with another 256 lists ( that are read > online and have the same structure as the list one)? > ( the first list must be saved in the previous step) You are giving det

Re: How to compare lists

2015-09-01 Thread Chris Angelico
On Tue, Sep 1, 2015 at 3:08 PM, Jahn wrote: > 1. > How can I save 256 lists, each list has 32 values( hexadecimal numbers) > 2. > How to compare the saved lists with another 256 lists ( that are read online > and have the > same structure as the list one)? > ( the first list must be saved in the

How to compare lists

2015-09-01 Thread Jahn
1. How can I save 256 lists, each list has 32 values( hexadecimal numbers) 2. How to compare the saved lists with another 256 lists ( that are read online and have the same structure as the list one)? ( the first list must be saved in the previous step) E.g Thanks -- https://mail.python.o

Re: Extra AttributeError inside property - possible bug ?

2015-09-01 Thread Peter Otten
dunric...@gmail.com wrote: > Hello, > > bellow is a simple Python2 example of a class which defines __getattr__ > method and a property, where AttributeError exception is raised: > > from __future__ import print_function > > class MyClass(object): > def __getattr__(self, name): > pr