This Python script cannot open by a editor?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Jul 4 19:37:30 EDT 2014


On Fri, 04 Jul 2014 14:50:02 -0700, rxjwg98 wrote:

> Hi,
> 
> I am learning a Python Tool from web:
> http://www.ohwr.org/projects/hdl-make/wiki/Quick-start-new

Did you read that web page? It says:

    To get the code you have two choices: you might clone the 
    repository, which contains the most recent changes (more 
    features, more bugs too...) or download a frozen version 
    in a form of a "binary" file.


> I download the program to Ubuntu 12.04. I find that in the folder it is
> shown as hdlmake-v1.0, 37.8 KB Python Script. 

At the bash shell from inside that folder, run:

    file hdlmake-v1.0


What does it say?



> I remember that script
> file can be loaded to an editor to read its content. But, when I open it
> by double click, it is shown as like binary file in GEDIT.
> 
> What is the reason of this?

Because it is a binary file.


> A general Python file has .py extension, and can be edited. Is it right?

Python *source code* normally has a .py extension, although it could have 
no extension at all.

Python *byte code* is a binary file, usually with a .pyc or .pyo 
extension. On Windows, sometimes you also get .pyw.

You can also get Python code inside a zip file, which may have a .zip 
extension. On Windows, you can get Python code frozen in a .exe file, and 
I believe on Mac you can get it frozen in a .app file.



-- 
Steven



More information about the Python-list mailing list