Filed Under (Editors, Python) by Marcin Kuźmiński on February-10-2010

makers of a great ruby on rails IDE rubymine, and ever greater Java IDE intelliJ, released
another (probably) great idea product named pycham, a python IDE, written from scratch in Java.

Since IntelliJ is a really the best Java IDE out there, i presume their next product
dedicated to python will be worth switching.

It’s still in preview but as for now it provides:

  • Coding Assistance
  • Project Code Navigation
  • Google App Engine Support
  • Code Analysis
  • Python Refactoring
  • Web Development with Django (some really nice ones)
  • debugger
  • Integrated unit tests
  • Version control integration



I’d tested under linux, seems to be a littler slower than my eclipse home brew version, but I’d expect the final version faster. It has few nice features, easy configuration, code completion are doing fine.
You can grab a free 45 day copy from here.

I’ll for sure fallow this product development. Stay posted for more !



Filed Under (Editors, Python) by Marcin Kuźmiński on November-20-2009

Few days ago there was again a major update on pydev eclipse plugin.
The version 1.5.1. Comes with new refactoring engine PEPTIC, it’s way better than any one before.
Complete list below: visit http://pydev.org for download.

Release 1.5.1

  • Improvements in the AST rewriter
  • Improvements on the refactoring engine:
    • No longer using BRM
    • Merged with the latest PEPTIC
    • Inline local available
    • Extract method bug-fixes
    • Extract local on multi-line
    • Generating properties using coding style defined in preferences
    • Add after current method option added to extract method
    • A bunch of other corner-case situations were fixed
  • Bug-fixes:
    • Minor editor improvements
    • Adding default forced builtins on all platforms (e.g.: time, math, etc) which wouldn’t be on sys.builtin_module_names on some python installations
    • Adding ‘numpy’ and ‘Image’ to the forced builtins always
    • Ctrl+1: Generate docstring minor fixes
    • Ctrl+1: Assign to local now follows coding style preferences properly
    • Exponential with uppercase E working on code-formatting
    • When a set/get method is found in code-completion for a java class an NPE is no longer thrown
    • Backspace properly treated in block mode
    • Setting IRONPYTHONPATH when dealing with Iron Python (projects could not be referenced)
    • No longer giving spurious ’statement has no effect’ inside of lambda and decorators
    • Fixed new exec in python 3k
    • Fixed NPE when breakpoint is related to a resource in a removed project
    • Fixed import problem on regexp that could lead to a recursion.
    • No longer giving NPE when debugging with the register view open
    • List access be treated as __getitem__() in the list — patch from Tassilo Barth
    • Fix for invalid auto-self added when typing


Filed Under (Editors) by Marcin Kuźmiński on September-6-2009

The creator of PyDev together with aptana released the version 1.5 of PyDev.This major release contains PyDev along with previously commercial non free PyDev extensions.
This is from now a Open Source project you could find on sourceforge
Pydev Extensions is a plugin that adds many other features to Pydev such as…

* code-analysis
* code completion with auto-import
* better implementation of go to definition
* remote debugging
* ‘quick-fixes’
* mark-occurrences <- this one is great :)

Before the PyDev extension was a paid plugin for aptana or eclipse.Now you could download it as PyDev 1.5 which is pyDev + pyDev extension merged together as a free open source project.
Great to here that :)

In order to install the pyDev 1.5 just update your eclipse repository to new update address which is http://pydev.org/updates

I think the nightly builds are yet not in 1.5 so I’ll use this repo for now.

Also i found a great link for PyDev functionality.

http://pydev.org/manual_adv_features.html

i did not know eclipse provide the ctrl+/ functionality (text auto completion emacs style…) This one is very handy !!

Enjoy new even better pyDev



Filed Under (Python) by Marcin Kuźmiński on July-1-2009

Here an example how to send a mail with attachement using built in smtp lib to multiple recipients. It’s really very simple in python.

Just take a look at the code bellow.

'simple smtp mailer with multiple recipients and file attachments'

from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
from email import encoders
import os
from smtplib import SMTP

class Mailer(object):
    ''' simple mailer  '''

    def __init__(self):

        self.mail_to = ['rec3@example.com', 'rec2@example.com', 'rec3@example.com']

        self.mail_from = 'mailer@python-blog.com'
        msg_en = "This is an automated message from python-blog.com\r\n"

        #path to file we want to attach
        msg_file_attachment = '/home/marcink/Desktop/pydev_icons.zip'
        #get the filename we need it for adding to mail header
        msg_file_name = os.path.basename(msg_file_attachment)

        smtp_serv = SMTP('mail.python-blog.com')

        smtp_serv.ehlo("simpleMailerHello.python-blog.com")

        #if server requires authorization you must provide login and password
        smtp_serv.login('mylogin', 'mypassword')
        date_ = formatdate(localtime = True)

        msg = MIMEMultipart()
        msg['From'] = self.mail_from
        msg['To'] = COMMASPACE.join(self.mail_to)
        msg['Date'] = date_
        msg['Subject'] = "example subject"

        #attach string message
        msg.attach(MIMEText(msg_en))

        #attach open encode the filename
        file_part = MIMEBase('application', "octet-stream")
        file_part.set_payload(open(msg_file_attachment, "rb").read())
        encoders.encode_base64(file_part)
        file_part.add_header('Content-Disposition', 'attachment; filename="%s"'
                       % msg_file_name)
        msg.attach(file_part)

        #sendmail and exit server
        smtp_serv.sendmail(self.mail_from, self.mail_to, msg.as_string())
        smtp_serv.quit()

if __name__ == "__main__":
    Mailer()
    print 'mail sent'


Filed Under (Editors, Python) by Marcin Kuźmiński on June-25-2009

Today is Eclipse Galileo release day. So i made my new PyDev + eclipse compilation with some customizations.

I remove all the unnecessary stuff for java IDE since we program in python we don’t need java stuff in there( and it loads faster to :D )
replaced splash screen with the one from pyDev site, and throw some nice (Python) window icons.

Here’s the main window:
Screenshot-Pydev - Eclipse

Here’s what you have to do to have my setup:

  • Get the newest version of eclipse for java IDE (not the EE) use this direct link if you want download eclipse
  • extract folder eclipse to you hard drive and rename it to let’s say PyDev ;]
  • DON’T RUN ECLIPSE !! please
  • Ok here’s what you have to remove to get rid of all the java stuff
    (i have nothing against java, but we’re talking python here)
  • from folder features remove org.eclipse.jdt_3.5.0.v20090527-2000-7r88FEeFJePyvYeA33DjZ_c1
  • from folder plugins remove
    org.eclipse.jdt.debug_3.5.0.v20090526
    org.eclipse.jdt.apt.core_3.3.200.v20090528-1135.jar
    org.eclipse.jdt.apt.pluggable.core_1.0.200.v20090526-2130.jar
    org.eclipse.jdt.apt.ui_3.3.200.v20090528-1135.jar
    org.eclipse.jdt.compiler.apt_1.0.200.v20090528-1135.jar
    org.eclipse.jdt.compiler.tool_1.0.100.v_963.jar
    org.eclipse.jdt.core.manipulation_1.3.0.v20090603.jar
    org.eclipse.jdt.core_3.5.0.v_963.jar
    org.eclipse.jdt.debug.ui_3.4.0.v20090527.jar
    org.eclipse.jdt.doc.user_3.5.0.v20090603-1530.jar
    org.eclipse.jdt.junit.runtime_3.4.100.v20090513-2000.jar
    org.eclipse.jdt.junit4.runtime_1.1.0.v20090513-2000.jar
    org.eclipse.jdt.junit_3.5.0.v20090526-2000.jar
    org.eclipse.jdt.launching_3.5.0.v20090527.jar
    org.eclipse.jdt.ui_3.5.0.v20090604.jar
    org.eclipse.jdt_3.5.0.v200906111540.jar
  • Firstly i decided to remove epp.package.java but this really screws up eclipse and the icons so don’t do it
  • Now download this pydev icons  package pydev_icons and extract it somewhere
    if you don’t need the eclipse icon replacement you can skip this.
  • Copy and replace splash.bmp to folder plugins/org.eclipse.platform_3.3.200.v200906111540
    and paste rest of images to folder in plugins/org.eclipse.epp.package.java_1.2.0.20090619-0620
  • In case of newer eclipse builds (3.5.2) just copy everything to plugins/org.eclipse.platform_*.*(version number) and remove the gifs, so eclipse will load png
  • Your done !

Now run eclipse save you workspace and setup pydev as in this post:

http://www.python-blog.com/index.php/2009/06/20/python-ide-pydev-best-choice/

Enjoy lighter version of newest eclipse galileo with Pydev and some nice icons :)

UPDATE: I changed the splash screen in pydev icons to be the same size as original one.



Filed Under (Editors, Python) by Marcin Kuźmiński on June-20-2009

I went through many of python editors, and always came back to PyDev. Pydev in an plug-in to eclipse it comes with load of features, among them:

  • Package Explorer showing outline for python modules
  • Mylyn integration (separate feature: org.python.pydev.mylyn.feature)
  • Jython and Python support!
  • Support for scripting Pydev with Jython
  • Nice PYTHONPATH configuration!
  • Project and module creation wizards
  • Ctrl+Shift+O: Organizes imports or sorts selection alphabetically
  • Ctrl+Shift+F: Autoformat your code (preferences can be set)
  • Python 2.4, 2.5, 2.6, 3.0 syntax supported
  • Pydev builders can be disabled
  • Syntax highlighting
  • Spell checking (depends on JDT for Eclipse 3.3)
  • Hovering in errors shows descriptions
  • Matching brackets highlighted.
  • Parser errors marked in the task list
  • Outline view with imports/functions/classes
  • Tabs or spaces preference
  • Smart indentation (indent and dedent)
  • Navigation: keyboard shortcuts to previous or next function. Default: (Ctrl+Shift+Up and Ctrl+Shift+Down)
  • Comment and uncomment commands (on the popup menu) and keybindings. Default: (Ctrl+3 and Ctrl+Shift+3)
  • hyperlinks over functions//import statements
  • Code folding
  • Refactoring with bicycle repair man.
  • Code Completion (Ctrl+Space)
  • Templates Completion (Ctrl+Space Too)
  • Go to definition with F3 (powered by bicycle repair man)
  • Content Assistant (Ctrl+1)
  • Code Coverage
  • Pylint
  • TODO tasks
  • Background and current line color chooser.

I highly recommend using Pylint in pydev it really helps to keep the code good quality. Pylint analyzes your code and shows unnecessary variables and imports, provides helpers to clean up the code and many more.

To install pydev just add http://pydev.sourceforge.net/updates/ http://pydev.org/updates (see update below) link to eclipse by using software updates and addons option.
I’m using the nightly builds for eclipse (http://nightly.aptana.com/pydev/) because they always come with new features earlier than the main release but remember use it on your own responsibility. You can find how to setup pydev here. When your up and running with pydev download pylint from here don’t forget the necessary dependencies i.e: logilab-astng, logilab-common, links are on the pylint download site. The turn on pylint you have to add a path to lint.py file in pylint tab on pydev options in eclipse. After restart of eclipse you should see output from pylint on the eclipse console anytime when you save a python file.

Now enjoy the most powerful python IDE available :-)

UPDATE: since PyDev release 1.5 now the package have integrated a pyDev extensions… the new repository for eclipse containing the version 1.5 is :http://pydev.org/updates
I also added a post about the PyDev extensions see it here http://www.python-blog.com/2009/09/06/pydev-extension-now-open-source/