Can I run a python program from within emacs?

Discussion in 'Python' started by jmDesktop, Mar 20, 2008.

  1. jmDesktop

    jmDesktop Guest

    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.
    jmDesktop, Mar 20, 2008
    #1
    1. Advertising

  2. On 2008-03-20, jmDesktop <> wrote:

    > 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
    Grant Edwards, Mar 20, 2008
    #2
    1. Advertising

  3. jmDesktop

    Jeff Schwab Guest

    Grant Edwards wrote:
    > On 2008-03-20, jmDesktop <> wrote:
    >
    >> 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.
    Jeff Schwab, Mar 20, 2008
    #3
  4. jmDesktop

    jmDesktop Guest

    On Mar 20, 11:21 am, Grant Edwards <> wrote:
    > On 2008-03-20, jmDesktop <> wrote:
    >
    > > 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.
    jmDesktop, Mar 20, 2008
    #4
  5. jmDesktop

    Jeff Schwab Guest

    jmDesktop wrote:
    > On Mar 20, 11:21 am, Grant Edwards <> wrote:
    >> On 2008-03-20, jmDesktop <> wrote:
    >>
    >>> 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?")
    Jeff Schwab, Mar 20, 2008
    #5
  6. Jeff Schwab wrote:
    > jmDesktop wrote:
    >> On Mar 20, 11:21 am, Grant Edwards <> wrote:
    >>> On 2008-03-20, jmDesktop <> wrote:
    >>>
    >>>> 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
    Paulo da Costa, Mar 20, 2008
    #6
  7. jmDesktop

    jmDesktop Guest

    On Mar 20, 11:44 am, Jeff Schwab <> wrote:
    > jmDesktop wrote:
    > > On Mar 20, 11:21 am, Grant Edwards <> wrote:
    > >> On 2008-03-20, jmDesktop <> wrote:

    >
    > >>> 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.
    jmDesktop, Mar 20, 2008
    #7
  8. On 2008-03-20, jmDesktop <> wrote:
    > On Mar 20, 11:21 am, Grant Edwards <> wrote:
    >> On 2008-03-20, jmDesktop <> wrote:
    >>
    >> > 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
    Grant Edwards, Mar 20, 2008
    #8
  9. On 2008-03-20, Jeff Schwab <> wrote:

    >>> 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
    Grant Edwards, Mar 20, 2008
    #9
  10. On 2008-03-20, jmDesktop <> wrote:

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

    --
    Grant
    Grant Edwards, Mar 20, 2008
    #10
  11. Grant Edwards wrote:

    > On 2008-03-20, Jeff Schwab <> wrote:
    >
    >>>> 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
    Diez B. Roggisch, Mar 20, 2008
    #11
  12. jmDesktop

    Jeff Schwab Guest

    Paulo da Costa wrote:

    > People who say Emacs often mean GNU Emacs.


    That's funny; to me, Emacs usually means XEmacs. :)
    Jeff Schwab, Mar 20, 2008
    #12
  13. jmDesktop

    Jeff Schwab Guest

    Grant Edwards wrote:
    > On 2008-03-20, Jeff Schwab <> wrote:
    >
    >>>> 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."
    Jeff Schwab, Mar 20, 2008
    #13
  14. 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
    Paulo da Costa, Mar 20, 2008
    #14
  15. On Mar 20, 3:09 pm, jmDesktop <> wrote:
    > 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!
    David Reitter, Mar 22, 2008
    #15
  16. jmDesktop

    Guest

    On Mar 22, 3:47 am, David Reitter <> wrote:
    > On Mar 20, 3:09 pm, jmDesktop <> wrote:
    >
    > > 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).


    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.
    , Mar 22, 2008
    #16
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pradeep nair
    Replies:
    2
    Views:
    534
  2. frankrentef

    Run program from within Python

    frankrentef, Aug 6, 2008, in forum: Python
    Replies:
    3
    Views:
    358
    frankrentef
    Aug 6, 2008
  3. Robinson
    Replies:
    2
    Views:
    2,160
  4. Robinson
    Replies:
    0
    Views:
    364
    Robinson
    Nov 1, 2009
  5. Adam Funk
    Replies:
    4
    Views:
    217
    Adam Funk
    Jan 29, 2007
Loading...

Share This Page