I'm very proud to announce the release of PySmell v0.7. PySmell is an auto-completion library for Python, meant to be plugged in different editors.

The big news for this release is the support for Emacs and TextMate, on top of the already existing Vim support. This isn't tested as rigorously as I'd like, so please report any issues at Google Code.

EDIT: PySmell 0.7.1 fixes a nasty TextMate bug, so please try again if you were put off by it!

Other niceties include module member completion, so doing:

import os
os.

Should give you the members of os. Same applies with any package/module, of course.

Also, a very simple form of duck inferencing has been added:

class A(object):
    pass

a = A()

a is recognised to be an instance of A. The next release will aim to extend this functionality.

Grab PySmell from PyPI, or you can follow the development at GitHub

Please give feedback in the comments below or at Google Code

November 2, 2008, 10:02 p.m. More (163 words) 22 comments Feed
Previous entry: Towards headless IDEs
Next entry: Control iChat from Python

Comments

1

Comment by Kevin , 1 year, 3 months ago :

Ok, this seems like a godsend, but how does one actually use it from inside vim while coding? I set the omnicomplete function to pysmell#Complete, created a PYSMELLTAGS file, and autocompletion did not work at all, i just got a bunch of errors, which repeated.

2

Comment by Rat , 1 year, 3 months ago :

I get the same problem as Kevin. Vim is unable to find the 'pysmell' module.

I can 'import pysmell' just fine using the command line but inside vim when I do ':python import pysmell' it can't find it.

3

Comment by Orestis Markou , 1 year, 3 months ago :

You have to make sure that Vim uses the python version that you used to install pysmell.

:python import sys; print sys.path

will give you a hint.

Unfortunately on Linux/MacOS you have to recompile Vim to link it to the desired python version; On Windows it picks up a dll automatically.

4

Comment by cartman , 1 year, 3 months ago :

Emacs mode doesn't seem to work, can't get any expansion on os., I'll report a bug when I get home.

5

Comment by Ori Peleg , 1 year, 3 months ago :

Cool! Any chance of integrating with IronPython Studio?

6

Comment by Orestis Markou , 1 year, 3 months ago :

cartman: You have to create a PYSMELLTAGS file for any package you want to use PySmell for; Have a look at the README to see how to generate it for the standard library.

7

Comment by Orestis Markou , 1 year, 3 months ago :

Ori: I don't plan to yet, but I can guide anyone who'd like to give it a shot :)

8

Comment by Panos Laganakos , 1 year, 3 months ago :

Thanks for the release Oresti :)

As for vim on the mac, there's a discussion[1] going on (macvim), if there's a way for it to load it dynamically.

[1] http://groups.google.com/group/vim_ma...

9

Comment by Benjamin Sergeant , 1 year, 3 months ago :

The vim taglist package (creating a window with a list of method / function name for the loaded buffer automatically calls ctags. Maybe pysmell should do the same because creating the PYSMELLTAGS manually is not the best option.

10

Comment by Orestis Markou , 1 year, 3 months ago :

Benjamin: That's certainly an option - I do have some tasks written in my TODO list that will facilitate this (eg. update the PYSMELLTAGS file every time a file changes) etc.

Would a .pysmell directory with all that stuff in be too obtrusive? Certainly not more than a shouty PYSMELLTAGS file?

11

Comment by Orestis Markou , 1 year, 3 months ago :

Just a heads up to anyone reporting problems on TextMate - I've uploaded 0.7.1 to PyPI which fixes a bunch of errors on TextMate, and adds better error handling in Vim.

12

Comment by cartman , 1 year, 3 months ago :

It works after generating tags for stdlib. But there is a bug,

re.<tab> completes fine but

re.co<tab> says no expansion found.

13

Comment by cartman , 1 year, 3 months ago :

One minor problem, README.markdown says ~/.vim/plugins but it should be ~/.vim/plugin at least it is so on Ubuntu.

14

Comment by Orestis Markou , 1 year, 3 months ago :

cartman: That's weird. It works fine on my machine. Could you enable the DEBUG mode (check the README) and attach the output at Google Code?

I'll correct the README re: plugins

15

Comment by teki , 1 year, 3 months ago :

On my mac:

my-mac:~/os/Pymacs-0.23 : pysmell
Traceback (most recent call last):
File "/usr/local/bin/pysmell", line 8, in <module>
load_entry_point('pysmell==0.7.1', 'console_scripts', 'pysmell')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2173, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1906, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
ImportError: No module named tags

16

Comment by Orestis Markou , 1 year, 3 months ago :

That's weird - could you report it in Google Code?

17

Comment by cartman , 1 year, 3 months ago :

Is there a way to enable debug in emacs?

18

Comment by Pierre R , 1 year, 3 months ago :

Sorry to ask a dumb question but is there a way to get completion for built-in function ?

I know there is no source for them so I don't know if a tag file can be generated.

Anyway I cannot find a way to get completion on a datetime object for instance.

Thanks for the plugin.

19

Comment by Orestis Markou , 1 year, 3 months ago :

Cartman: sorry, no - you can hack something together though if you have a look at emacshelper.py

Pierre: There's no completion for any function implemented in C - I plan to fix that at some point by manually generating TAGS for them.

20

Comment by Pierre R , 1 year, 2 months ago :

Thx for the information.

Sorry to bother you again but there is something I don't seem to catch in the way Vim completion works. I know it is not PySmell related but well I would appreciate any help.

I start completion using C-X C-O or another mapping. I get a nice list that can be long if I did not type anything after the ".". Now in most editor I would simply type the next letter and the list would schrink. Nothing similar in Vim. Vim take the first one in the list by default and the only way to choose something else is to use C-o or C-n or whatever to scroll the list or to cancel using C-e.

This is so annoying and I do not seem to find the way to customize the behaviour.

Do you see what I mean ? Spe a Python editor is doing exactly what I want. It seems much more intuitive to me.

The default behaviour of Vim omnicompletion is poor unless I am missing something.

Thanks for your help.

21

Comment by Orestis Markou , 1 year, 2 months ago :

Pierre: You're right, Vim's default system for omnicompletion is not very helpful. Here's what works for me:

set completeopt=menuone,longest

longest is probably what you want.

22

Comment by Pierre , 1 year, 2 months ago :

Thanks. A bit better but still not as good as what I am used to in my shell or IPython.

I still don't get it. What about:

import calendar

cal= calendar.Calendar() # Ok so far

weeksIter = cal.iterweekdays()
weeksIter. # nok for completion such as next

IPython handle this rightly.

Would be nice to know what the plugin add compare to the default pythoncomplete#Complete ?

No offense really. I just try to make the most of it ;-)

Thanks for the valuable advice. There is probably a better place to discuss the plugin in detail. I will try to find out.


This post is older than 30 days and comments have been turned off.