FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 07-07-2010, 12:36 AM
Jim Byrnes
 
Default Running a Python file

I have been teaching myself Python. Running some of my programs and
others examples I noticed that some I could run by double-clicking them
and others I could not. Looking at the file permissions I saw that they
were different. Then I noticed that all the ones I could not run were
ones I gone into Properties-->Permissions and check execute as a
program. Once I unchecked it they worked.

This seems backwards to me. Could someone tell me why this works this way?

Thanks, Jim

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 07-07-2010, 01:13 AM
Pete Vander Giessen
 
Default Running a Python file

On Tue, Jul 6, 2010 at 5:36 PM, Jim Byrnes <jf_byrnes@comcast.net> wrote:
> I have been teaching myself Python. *Running some of my programs and
> others examples I noticed that some I could run by double-clicking them
> and others I could not. *Looking at the file permissions I saw that they
> were different. *Then I noticed that all the ones I could not run were
> ones I gone into Properties-->Permissions and check execute as a
> program. *Once I unchecked it they worked.
>
> This seems backwards to me. *Could someone tell me why this works this way?

Hi Jim,

That _is_ backwards. What do you mean by "run"? The default behavior
in Ubuntu, when you double-click an executable script, is to prompt
whether you want to "display", cancel, or run the script. The default
behavior for a non-executable script is to open it up in your default
text editor.

I'm guessing that you are using an IDE to write your Python, and when
you double click a non-executable file, it opens it up in the IDE, and
then your IDE executes it. When you double-click an executable file
on the other hand, it is simply executing it and exiting, too fast for
you to notice. Does this sound plausible?

Regardless, have fun with Python. It's an excellent language, and
generally a pleasure to code.

~PeteVG

" ... the original aphorism being 'In comparison with the ancients, we
stand like dwarfs on the shoulders of giants.' The image was a
commonplace by the time Newton used it, his one contribution being to
erase any sense that he himself might be a dwarf."

~ Lewis Hyde

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 07-07-2010, 01:13 AM
Cameron Hutchison
 
Default Running a Python file

Jim Byrnes <jf_byrnes@comcast.net> writes:

>I have been teaching myself Python. Running some of my programs and
>others examples I noticed that some I could run by double-clicking them
>and others I could not. Looking at the file permissions I saw that they
>were different. Then I noticed that all the ones I could not run were
>ones I gone into Properties-->Permissions and check execute as a
>program. Once I unchecked it they worked.

>This seems backwards to me. Could someone tell me why this works this way?

If your python program is executable, it must have a first line of
something line this:
#!/usr/bin/python

or sometimes

#!/usr/bin/env python

If you don't have this line, the kernel will not be able to execute it.
For more info on this first line, see:
http://en.wikipedia.org/wiki/Shebang_(Unix)

If you turn off execute permission, I assume that the file manager
recognises that the file is a python program (with the .py extension)
and runs the python interpreter for you (from the command line, this
would look like: "python file.py"). Without the file manager doing
something like this, the program would not be executable. It is likely
the same logic used when you double-click an openoffice.org document
(for example). Openoffice.org is launched with the double-clicked file
as an argument.


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 07-07-2010, 01:59 AM
Jim Byrnes
 
Default Running a Python file

Cameron Hutchison wrote:
> Jim Byrnes<jf_byrnes@comcast.net> writes:
>
>> I have been teaching myself Python. Running some of my programs and
>> others examples I noticed that some I could run by double-clicking them
>> and others I could not. Looking at the file permissions I saw that they
>> were different. Then I noticed that all the ones I could not run were
>> ones I gone into Properties-->Permissions and check execute as a
>> program. Once I unchecked it they worked.
>
>> This seems backwards to me. Could someone tell me why this works this way?
>
> If your python program is executable, it must have a first line of
> something line this:
> #!/usr/bin/python
>
> or sometimes
>
> #!/usr/bin/env python

I should have read my message over before I sent it, I left out two
things. I have the Shebang line the programs are GUI (wxPython)

> If you don't have this line, the kernel will not be able to execute it.
> For more info on this first line, see:
> http://en.wikipedia.org/wiki/Shebang_(Unix)
>
> If you turn off execute permission, I assume that the file manager
> recognises that the file is a python program (with the .py extension)
> and runs the python interpreter for you (from the command line, this
> would look like: "python file.py"). Without the file manager doing
> something like this, the program would not be executable. It is likely
> the same logic used when you double-click an openoffice.org document
> (for example). Openoffice.org is launched with the double-clicked file
> as an argument.
>
This explanation is exactly what I needed to get it straight in my
head.The file is not executing, something else (the
interperter/OpenOffice) is executing and using the file.

Thanks for the explanation.

Regards, Jim



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 07-07-2010, 02:08 AM
Jim Byrnes
 
Default Running a Python file

Pete Vander Giessen wrote:
> On Tue, Jul 6, 2010 at 5:36 PM, Jim Byrnes<jf_byrnes@comcast.net> wrote:
>> I have been teaching myself Python. Running some of my programs and
>> others examples I noticed that some I could run by double-clicking them
>> and others I could not. Looking at the file permissions I saw that they
>> were different. Then I noticed that all the ones I could not run were
>> ones I gone into Properties-->Permissions and check execute as a
>> program. Once I unchecked it they worked.
>>
>> This seems backwards to me. Could someone tell me why this works this way?
>
> Hi Jim,
>
> That _is_ backwards. What do you mean by "run"? The default behavior
> in Ubuntu, when you double-click an executable script, is to prompt
> whether you want to "display", cancel, or run the script. The default
> behavior for a non-executable script is to open it up in your default
> text editor.
>
> I'm guessing that you are using an IDE to write your Python, and when
> you double click a non-executable file, it opens it up in the IDE, and
> then your IDE executes it. When you double-click an executable file
> on the other hand, it is simply executing it and exiting, too fast for
> you to notice. Does this sound plausible?

See my reply to Cameron. I was thinking wrong. I was thinking the
script had to be executable instead of the python interpreater was
executing the script.

> Regardless, have fun with Python. It's an excellent language, and
> generally a pleasure to code.

That it is, I just program for my own enjoyment.

> ~PeteVG
>

regards, Jim

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 06:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org