By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,676 Members | 2,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,676 IT Pros & Developers. It's quick & easy.

Can I run a python program from within emacs?

P: n/a
Hi, I'm trying to learn Python. I using Aquamac an emac
implementation with mac os x. I have a program. If I go to the
command prompt and type pythong myprog.py, it works. Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. On Python do I use the
editor for editing only and then run the program from the command
line? Thank you.
Mar 20 '08 #1
Share this Question
Share on Google+
14 Replies


P: n/a
On 2008-03-20, jmDesktop <ne***********@gmail.comwrote:
Hi, I'm trying to learn Python. I using Aquamac an emac
implementation with mac os x. I have a program. If I go to the
command prompt and type pythong myprog.py, it works. Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. On Python do I use the
editor for editing only and then run the program from the command
line?
http://www.google.com/search?q=emacs+python

--
Grant

Mar 20 '08 #2

P: n/a
Grant Edwards wrote:
On 2008-03-20, jmDesktop <ne***********@gmail.comwrote:
>Hi, I'm trying to learn Python. I using Aquamac an emac
implementation with mac os x. I have a program. If I go to the
command prompt and type pythong myprog.py, it works. Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. On Python do I use the
editor for editing only and then run the program from the command
line?

http://www.google.com/search?q=emacs+python
Or achieve a similar (more flexible (IMO), but less smoothly integrated)
effect with Vim and GNU Screen. Until recently, you had to patch Screen
if you wanted vertical splits, but now it's in the main line.
Mar 20 '08 #3

P: n/a
On Mar 20, 11:21*am, Grant Edwards <gra...@visi.comwrote:
On 2008-03-20, jmDesktop <needin4mat...@gmail.comwrote:
Hi, I'm trying to learn Python. *I using Aquamac an emac
implementation with mac os x. *I have a program. *If I go to the
command prompt and type pythong myprog.py, it works. *Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. *On Python do I use the
editor for editing only and then run the program from the command
line?

http://www.google.com/search?q=emacs+python

--
Grant
Gee. Thanks.
Mar 20 '08 #4

P: n/a
jmDesktop wrote:
On Mar 20, 11:21 am, Grant Edwards <gra...@visi.comwrote:
>On 2008-03-20, jmDesktop <needin4mat...@gmail.comwrote:
>>Hi, I'm trying to learn Python. I using Aquamac an emac
implementation with mac os x. I have a program. If I go to the
command prompt and type pythong myprog.py, it works. Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. On Python do I use the
editor for editing only and then run the program from the command
line?
Sort of. Modern editors generally have support for building and running
your program directly from a toolbar button or textual command. I
personally use Vim with the toolbar disabled, running in a Terminal, and
run the program by first putting Vim in the background (^z).

People writing code specific to Mac, but not necessarily all in Python,
often use XCode.

http://zovirl.com/2006/07/13/xcode-python/

In the Ruby community, Vim is the dominant choice, but a lot of Mac
users swear by TextMate.

http://macromates.com/
>http://www.google.com/search?q=emacs+python
Gee. Thanks.
I believe Grant was suggesting that Emacs often serves a similar purpose
on Unix to what Visual Studio does on Windows, which seemed to be what
you were asking. When asking about Mac OS X here, you are likely to get
a lot of generic Unix responses. (Would it have been clearer if he had
just said "emacs?")
Mar 20 '08 #5

P: n/a
Jeff Schwab wrote:
jmDesktop wrote:
>On Mar 20, 11:21 am, Grant Edwards <gra...@visi.comwrote:
>>On 2008-03-20, jmDesktop <needin4mat...@gmail.comwrote:

Hi, I'm trying to learn Python. I using Aquamac an emac
implementation with mac os x. I have a program. If I go to the
command prompt and type pythong myprog.py, it works. Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. On Python do I use the
editor for editing only and then run the program from the command
line?

Sort of. Modern editors generally have support for building and running
your program directly from a toolbar button or textual command. I
personally use Vim with the toolbar disabled, running in a Terminal, and
run the program by first putting Vim in the background (^z).
Modern editors like GNU Emacs show you a Python tab when you're editing
a Python file that allows you to do various things with the code, just
like Visual Studio, I don't know about "Aquamacs".
I believe Grant was suggesting that Emacs often serves a similar purpose
on Unix to what Visual Studio does on Windows, which seemed to be what
you were asking. When asking about Mac OS X here, you are likely to get
a lot of generic Unix responses. (Would it have been clearer if he had
just said "emacs?")
There are several flavors, it's best to specify which one you mean.
People who say Emacs often mean GNU Emacs.

Paulo
Mar 20 '08 #6

P: n/a
On Mar 20, 11:44*am, Jeff Schwab <j...@schwabcenter.comwrote:
jmDesktop wrote:
On Mar 20, 11:21 am, Grant Edwards <gra...@visi.comwrote:
On 2008-03-20, jmDesktop <needin4mat...@gmail.comwrote:
>Hi, I'm trying to learn Python. *I using Aquamac an emac
implementation with mac os x. *I have a program. *If I go to the
command prompt and type pythong myprog.py, it works. *Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. *On Python do I use the
editor for editing only and then run the program from the command
line?

Sort of. *Modern editors generally have support for building and running
your program directly from a toolbar button or textual command. *I
personally use Vim with the toolbar disabled, running in a Terminal, and
run the program by first putting Vim in the background (^z).

People writing code specific to Mac, but not necessarily all in Python,
often use XCode.

* * *http://zovirl.com/2006/07/13/xcode-python/

In the Ruby community, Vim is the dominant choice, but a lot of Mac
users swear by TextMate.

* * *http://macromates.com/
>http://www.google.com/search?q=emacs+python
Gee. *Thanks.

I believe Grant was suggesting that Emacs often serves a similar purpose
on Unix to what Visual Studio does on Windows, which seemed to be what
you were asking. *When asking about Mac OS X here, you are likely to get
a lot of generic Unix responses. *(Would it have been clearer if he had
just said "emacs?")
No. Typically when someone posts a one-liner search it means go
figure it out and stop bothering "us." I had already searched. I
could not get it to work, which is why I posted. If I took it wrong I
apologize.

I really had two questions. One is just how to run a program from
within the editor and the other is if my thinking on how development
is done in python wrong to start with. Most of my non-Windows
programs have been on Unix using vi, but it has been a while. I'm
used to writing a program in visual studio and running it. If that's
the wrong expectation for python programming in emacs, then I wanted
to know.

Thanks for your help.
Mar 20 '08 #7

P: n/a
On 2008-03-20, jmDesktop <ne***********@gmail.comwrote:
On Mar 20, 11:21*am, Grant Edwards <gra...@visi.comwrote:
>On 2008-03-20, jmDesktop <needin4mat...@gmail.comwrote:
Hi, I'm trying to learn Python. *I using Aquamac an emac
implementation with mac os x. *I have a program. *If I go to the
command prompt and type pythong myprog.py, it works. *Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. *On Python do I use the
editor for editing only and then run the program from the command
line?

http://www.google.com/search?q=emacs+python

Gee. Thanks.
Golly. You're welcome. Don't the hits on the first page
answer your question? They explain how to do things like run
python programs from within emacs (including how to do
source-level debugging).

This is probably one of the better pages that the google search
above found:

http://wiki.python.org/moin/EmacsEditor

--
Grant
Mar 20 '08 #8

P: n/a
On 2008-03-20, Jeff Schwab <je**@schwabcenter.comwrote:
>>http://www.google.com/search?q=emacs+python
>Gee. Thanks.

I believe Grant was suggesting that Emacs often serves a similar purpose
on Unix to what Visual Studio does on Windows, which seemed to be what
you were asking. When asking about Mac OS X here, you are likely to get
a lot of generic Unix responses. (Would it have been clearer if he had
just said "emacs?")
Don't the normal "run/debug python from inside emacs" methods
work on OS-X?

--
Grant

Mar 20 '08 #9

P: n/a
On 2008-03-20, jmDesktop <ne***********@gmail.comwrote:
>I believe Grant was suggesting that Emacs often serves a
similar purpose on Unix to what Visual Studio does on Windows,
which seemed to be what you were asking. *When asking about
Mac OS X here, you are likely to get a lot of generic Unix
responses. *(Would it have been clearer if he had just said
"emacs?")

No. Typically when someone posts a one-liner search it means
go figure it out and stop bothering "us." I had already
searched. I could not get it to work,
Could not get what to work?
which is why I posted. If I took it wrong I apologize.
I honestly thought you were asking how to run/debug python
programs inside emacs. A couple of the hits answered that
question. The others explained how do get python-aware editing
modes configured.
I really had two questions. One is just how to run a program from
within the editor and the other is if my thinking on how development
is done in python wrong to start with. Most of my non-Windows
programs have been on Unix using vi, but it has been a while. I'm
used to writing a program in visual studio and running it.
Perhaps you'd be more comfortable with one of the IDEs?

http://wiki.python.org/moin/Integrat...ntEnvironments
http://en.wikipedia.org/wiki/Compari...onments#Python
If that's the wrong expectation for python programming in
emacs, then I wanted to know.
Yes, you can run programs (including python debuggers) from
inside emacs. The simplest way is to do "meta-x shell" to get
a shell prompt inside emacs, then just type whatever command
line you want to use to run the program. Or you can map a
command to a keystroke that will run the program.

I generally just have another terminal window open where I run
the program -- but I've never liked IDEs so your tastes may
differ.

--
Grant
Mar 20 '08 #10

P: n/a
Grant Edwards wrote:
On 2008-03-20, Jeff Schwab <je**@schwabcenter.comwrote:
>>>http://www.google.com/search?q=emacs+python
>>Gee. Thanks.

I believe Grant was suggesting that Emacs often serves a similar purpose
on Unix to what Visual Studio does on Windows, which seemed to be what
you were asking. When asking about Mac OS X here, you are likely to get
a lot of generic Unix responses. (Would it have been clearer if he had
just said "emacs?")

Don't the normal "run/debug python from inside emacs" methods
work on OS-X?
Of course they do.

Diez
Mar 20 '08 #11

P: n/a
Paulo da Costa wrote:
People who say Emacs often mean GNU Emacs.
That's funny; to me, Emacs usually means XEmacs. :)
Mar 20 '08 #12

P: n/a
Grant Edwards wrote:
On 2008-03-20, Jeff Schwab <je**@schwabcenter.comwrote:
>>>http://www.google.com/search?q=emacs+python
Gee. Thanks.
I believe Grant was suggesting that Emacs often serves a similar purpose
on Unix to what Visual Studio does on Windows, which seemed to be what
you were asking. When asking about Mac OS X here, you are likely to get
a lot of generic Unix responses. (Would it have been clearer if he had
just said "emacs?")

Don't the normal "run/debug python from inside emacs" methods
work on OS-X?
AFAIK, yes; I don't see why it wouldn't. I missed the word "emacs" in
the subject header, and did not recognize "an emac" in the original post
as meaning "emacs."
Mar 20 '08 #13

P: n/a
Jeff Schwab wrote:
Paulo da Costa wrote:
>People who say Emacs often mean GNU Emacs.

That's funny; to me, Emacs usually means XEmacs. :)
Which is often a cause of confusion.

Paulo
Mar 20 '08 #14

P: n/a
On Mar 20, 3:09 pm, jmDesktop <needin4mat...@gmail.comwrote:
Hi, I'm trying to learn Python. I using Aquamac an emac
implementation with mac os x. I have a program. If I go to the
command prompt and type pythong myprog.py, it works. Can the program
be run from within the editor or is that not how development is done?
I ask because I was using Visual Studio with C# and, if you're
familiar, you just hit run and it works. On Python do I use the
editor for editing only and then run the program from the command
line? Thank you.
Aquamacs, just like any variant of GNU Emacs, will show a Python
menu. There's a "Start Interpreter" function, and one to evaluate the
buffer (C-c C-c). It's pretty straightforward (a euphemism for
obvious).

If the Python menu doesn't show, then something is going wrong. M-x
python-mode RET would switch it on.
--
http://aquamacs.org -- Aquamacs: Emacs on Mac OS X
http://aquamacs.org/donate -- Could we help you? Return the favor and
support the Aquamacs Project!
Mar 22 '08 #15

This discussion thread is closed

Replies have been disabled for this discussion.