473,545 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

writing Python in Emacs

Hi All,

I am a devoted Emacs user and I write a lot in Python. However, I
never managed to get my Emacs configuration right for this purpose.
There were some discussions on this, but the threads that show if I
search the group are either old or not so relevant.

I need the following features:

0) Of course, syntax coloring and so on... But this works good enough
ootb in the two most popular python-modes.

1) Tab completion, ideally Slime like. That is, when there's not
enough letters to unambiguously complete a symbol, I want it to show a
buffer (w/o taking the focus) w/ the possible completions. In an ideal
world, it would be able to complete fo.ba<TABto foo.bar. I imagine
this would require quite tight Emacs-Python integration.

2) Sending the toplevel definition (class or function) to the Python
buffer.

3) Hints on function/method arguments. IDLE has this done nearly
right, but the hints are a bit too intrusive for me. I would like to
see them in the minibuffer.

4) (optional) I would like to see the definition of a function
function or class by hitting M-. on its name. (I understand that this
may be impossible for methods, as Emacs would have to automagically
infer the type of the object).

I have tried a couple of times both python-modes (the one shipped w/
Python and the one shipped w/ Emacs), pymacs and stuff like that...
And, as I said, never got it right. But, maybe I just cannot find the
way to configure it, and some configuration hints will be enough...

As for other editors, I have tried Eclipse and Komodo... But I cannot
get used to them. As for non-emacs stuff, the most comfortable for me
has been IDLE.

Cheers and thanks in advance,

-- Richard
Jan 19 '08 #1
4 4374
>>>>"Richard" == Richard Szopa <ry***********@ gmail.comwrites :

RichardI am a devoted Emacs user and I write a lot in Python.

Me too.

RichardI need the following features:

Richard1) Tab completion, ideally Slime like. That is, when there's not
Richardenough letters to unambiguously complete a symbol, I want it to
Richardshow a buffer (w/o taking the focus) w/ the possible
Richardcompleti ons. In an ideal world, it would be able to complete
Richardfo.ba<TA Bto foo.bar. I imagine this would require quite tight
RichardEmacs-Python integration.

I know this is not what you want, but I use hippie expand (M-/) to cycle
through possible completions. It's not Python aware, but it is of some use.

Richard2) Sending the toplevel definition (class or function) to the Python
Richardbuffer.

I switched to IPython to have better interaction with a spawned Python.

To use IPython you need to use the Python mode that is NOT the one from
(endorsed?) by the FSF. It gives you some completion (at least in the
*Python* buffer) and you can send pieces of the buffer to the python
process, via py-send-region (C-c |), py-execute-def-or-class (M-C-x), etc.

Richard3) Hints on function/method arguments. IDLE has this done nearly
Richardright, but the hints are a bit too intrusive for me. I would like to
Richardsee them in the minibuffer.

I don't have this.

Richard4) (optional) I would like to see the definition of a function
Richardfunction or class by hitting M-. on its name. (I understand that
Richardthis may be impossible for methods, as Emacs would have to
Richardautomagi cally infer the type of the object).

This is just an emacs tag file need. Have you googled for something like
emacs tags python? The issue of methods might be overcome by just moving
through tags with the same name. Yes, that requires _you_ to know when
you've hit the right thing. That's not optimal, but it's better than
nothing. Ideally you could send the definition to IPython, ask it for the
class info, and use that to jump to the right tag.

RichardI have tried a couple of times both python-modes (the one shipped w/
RichardPython and the one shipped w/ Emacs), pymacs and stuff like that...
RichardAnd, as I said, never got it right. But, maybe I just cannot find the
Richardway to configure it, and some configuration hints will be enough...

If you have the time, please summarize your findings. The emacs/python
world has always seemed quite amorphous to me too.

Terry
Jan 19 '08 #2

I add just a note about ipython:
if you use a version 0.6.15 may be you will have a bad output
on error like:

== " ":
instead of:
if __name__ == "__main__":

all the characters are missing.

To avoid that, run in ipython:
%upgrade -nolegacy

uncomment in ~/.ipython/ipy_user_config .py:
import ipy_defaults

restart emacs and try a .py with some syntax errors.
It should be ok now.

Terry Jones <te***@jon.eswr ites:
>>>>>"Richard " == Richard Szopa <ry***********@ gmail.comwrites :

RichardI am a devoted Emacs user and I write a lot in Python.

Me too.

RichardI need the following features:

Richard1) Tab completion, ideally Slime like. That is, when there's not
Richardenough letters to unambiguously complete a symbol, I want it to
Richardshow a buffer (w/o taking the focus) w/ the possible
Richardcompleti ons. In an ideal world, it would be able to complete
Richardfo.ba<TA Bto foo.bar. I imagine this would require quite tight
RichardEmacs-Python integration.

I know this is not what you want, but I use hippie expand (M-/) to cycle
through possible completions. It's not Python aware, but it is of some use.

Richard2) Sending the toplevel definition (class or function) to the Python
Richardbuffer.

I switched to IPython to have better interaction with a spawned Python.

To use IPython you need to use the Python mode that is NOT the one from
(endorsed?) by the FSF. It gives you some completion (at least in the
*Python* buffer) and you can send pieces of the buffer to the python
process, via py-send-region (C-c |), py-execute-def-or-class (M-C-x), etc.

Richard3) Hints on function/method arguments. IDLE has this done nearly
Richardright, but the hints are a bit too intrusive for me. I would like to
Richardsee them in the minibuffer.

I don't have this.

Richard4) (optional) I would like to see the definition of a function
Richardfunction or class by hitting M-. on its name. (I understand that
Richardthis may be impossible for methods, as Emacs would have to
Richardautomagi cally infer the type of the object).

This is just an emacs tag file need. Have you googled for something like
emacs tags python? The issue of methods might be overcome by just moving
through tags with the same name. Yes, that requires _you_ to know when
you've hit the right thing. That's not optimal, but it's better than
nothing. Ideally you could send the definition to IPython, ask it for the
class info, and use that to jump to the right tag.

RichardI have tried a couple of times both python-modes (the one shipped w/
RichardPython and the one shipped w/ Emacs), pymacs and stuff like that...
RichardAnd, as I said, never got it right. But, maybe I just cannot find the
Richardway to configure it, and some configuration hints will be enough...

If you have the time, please summarize your findings. The emacs/python
world has always seemed quite amorphous to me too.

Terry
_______________ _______________ _______________ __
help-gnu-emacs mailing list
he************@ gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
--
A + Thierry
Pub key: http://pgp.mit.edu
Jan 19 '08 #3

Thanks Rob. Your code should basically do the trick.

-- Richard

Jan 31 '08 #4

Rob Wolfe wrote:
The good news is that I managed to configure completion for Python
in Emacs using pymacs, python-mode.el, pycomplete.el and pycomplete.py.
For contents of my pycomplete.el, pycomplete.py and necessary
settings in .emacs see below.
Thanks for that! I've been hoping something like this landed on my
lap for years.

Jan 31 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
4072
IDE
by: Thomas Lindgaard | last post by:
Hello I am probably going to start a war now... but so be it :) I just want to hear what all you guys who eat pythons for breakfast use for python coding. Currently I use Kate, but I would really like an IDE with debugger and a source browser (ie. one the I can use to browse through modules etc. when looking for just the right curses...
81
4621
by: julio | last post by:
Sorry but there is no another way, c# .net and mono are going to rip python, not because python is a bad lenguage, but because is to darn old and it refuses to innovate things, to fix wrong things, just because retarded backwards compatibility and because the python comunity and developers refuses to consider tools as being almost as important...
102
6964
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality of its documentation, it is a impeccability. it has or possesses properties of:
12
2808
by: Thomas Bartkus | last post by:
Does anyone use emacs together with both WordStar key bindings and python mode? I'm afraid that Wordstar editing key commands are burned R/O into my knuckles! I would like to play with emacs for Python editing but I'm having (2) problems. 1) When I load a .py file, emacs automatically overrides my wordstar-mode with python-mode, forcing...
19
1654
by: Vincent Delporte | last post by:
Hello I'm thinking of using Python to build the prototype for a business web appplication. The development and test machine is XP, while ultimate deployment will be on a shared Unix web host. What would you recommend I get, besides the Python engine itself? Good IDE (Kodomo?) ? Some kind of GUI designer? Add-on's? Other tools? Thank...
8
4214
by: Dave Potts | last post by:
Hi, I'm just starting a development project in Python having spent time in the Java world. I was wondering what tool advice you could give me about setting up a continuous integration environment for the python code: get the latest source, run all the tests, package up, produce the docs, tag the code repository. I'm used to things like...
4
3172
by: emin.shopper | last post by:
Emacs seems to freeze when doing certain shell commands on Microsoft Windows. The following is a simple example with Xemacs: ---------------------------------------------------------- Microsoft Windows XP (C) Copyright 1985-2001 Microsoft Corp.
7
2120
by: Michele Simionato | last post by:
I have noticed that the python-mode for Emacs that comes with the latest Ubuntu is missing the class browser. Moreover if works differently from the python-mode I was used to (for instance CTRL-c-c works as CTRL-c-! whereas CTRL-c-! is missing, etc). How can I go back to the old python-mode or at least how do I get back the class browser? ...
0
1243
by: xahlee | last post by:
Here's a little tutorial that lets you write emacs commands for processing the current text selection in emacs in your favorite lang. Elisp Wrapper For Perl Scripts http://xahlee.org/emacs/elisp_perl_wrapper.html plain text version follows. ------------------------------------- Elisp Wrapper For Perl Scripts
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7757
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.