Can I run a python program from within emacs?

J

jmDesktop

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.
 
G

Grant Edwards

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
 
J

Jeff Schwab

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/
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?")
 
P

Paulo da Costa

Jeff said:
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
 
J

jmDesktop

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/


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.
 
G

Grant Edwards

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?
 
G

Grant Edwards

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/IntegratedDevelopmentEnvironments
http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#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.
 
J

Jeff Schwab

Grant said:
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."
 
D

David Reitter

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.
 
C

castironpi

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).

Aside:

Straightforward may not be completely objective, i.e. have a metric/
unique metric. If perception & cognition are points on and paths
through a multi-dimensional space (densities in which limited by sense
mechanism), straightforward under its most literal interpretation,
means, 'in a straight line in the direction you're facing'. Straight
could mean an elementary, transcendantal, or composite function (say,
a sum of three sine waves). But forward leaves less to imagine. If
two ships cross, and one captain says, 'Bermuda? Sure. It's straight
forward,' to the other, he travels for a day and doesn't get there,
and he's angry, does he feel and/or believe that the first captain
provoked him, did he, and does he know it.

Straightforward doesn't necessarily evaluate to a concrete move
sequence in chess ('The pin is straightforward'); forward is ambiguous
(my forward, your forward, the formal forward), and straight is too.
In a depth-first search (unspecified), straight means move the same
piece repeatedly. In breadth-first, straight means you know exactly
my node weights. Forward means I know which direction you're facing,
or I'm following you. Both are resent-worthy assumptions: If you lose
me or I lose you, it's still your fault.

I take that back: either party can slack on following protocol; both
are following one. There's a ball, who dropped it (and who's on it!).

"Obvious", come to think of it, is pretty subjective too. The objects
and their respective distances away in one's perceptive(/cognitive)
environment vary from person to person, time to time ("by person by
time"). If you're telling me something is obvious, one of us made an
out-of-band inference.

I'm not sure what to think of the prevalence of human
miscommunications. Upon discovering one, either cut and go, or go
back for it; it's a sunken cost. (Is it a, 'I forgot to bring
something' on an embarked voyage (road trip), in the metaphor of ship
travel?) Do those both generate fights? There's social profit in
commerce-- but people are making some damn foolish partnerships.
(Even exclusivity can be profitable, but for some reason, 'exclusivity
agreement' isn't in Wikipedia, under exclusivity, marketing, marketing
strategy, or consumer engagement. 'Product bundling' is a good place
to start though-- lower marginal cost -and- higher marginal utility.
('Bundling' is also a social practice in the Netherlands!) Also see
law of excluded middle.)

Back to the exam: If A knows B's 'straight' and 'forward', maybe it
can be helpful, merely advising, 'don't take any turns and you won't
miss it (undershoot or overshoot)', which does take knowledge of
steering, just not of the terrain. It's just that if I don't know how
to stay on course, (not to turn), I'll still resent you. Not to
mention, a 'great circle straight' isn't the same as a Euclidian one.

It's possible, though, in the economy of social transaction, that "I"
don't "have time" to "take you there", all of those being defined
earlier: one of the parties can't afford to board, possibly return,
tow, or tie you, or it isn't profitable. It's possible your ship
can't take the tow too.

Notwithstanding, in the domain of collective social entities (many-
small/organisms), other senses of channel symbols / band symbols can
arise. "That doesn't mean the same thing back home / back in the
channel." I don't like learning the hard way-- by definition. But
the solution to the 'rich bully dilemma' is pretty much boycott-- cf.
Nash and optimal equilibrium. (That's optimal, not optical.) In
light of some certain "mental health" observations too, if boycotts
fail, protest is plan B.

Mere incompetence on either part is pretty easy to fix. It's the
'incompetent rich bully' who interferes with everybody else.

Nothing personal to the poster-- he covered his socal bases-- just
being thorough.

Last thing-- does "maintain forever" mean deal with us? Hush. A
pretty small group could build/anchor an outland base and maintain
people there forever, just with ferry trips back in. Past a certain
radius too (from hubs), bases become polynomially sparser-- just move
in with the monkey on your back, and we'll all get orbits around the
sun.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top