Yesterday I found that JetBrains released a new Early Access Program build (build 96.1203) of PyCharm, the newest multiplatform (Windows, Mac OS X, Linux) Python IDE,

They’ve made a lot of progress since I last checked and so it’s a good opportunity to give it a quick try and share my experience.

Installing

First, I downloaded the preview build (pycharm-96.1203.exe).

image

image

image

image

image

image

image

Launching and Starting a new Project

After installation, it will appear under the folder JetBrains in the Start Menu

image

Obligatory splash screen …

image

After it fully loads, you’ll be presented with this start experience.

image

We’ll start by creating a new project in the Quick Start area

image

As you would expect this can also be done from the File menu

image

You’ll be presented with this dialog to provide a name and a location for the project.

(Note to all developers: Don’t set the default for a file to the root of the user profile as shown below (“C:\Users\saveenr\PycharmProjects\untitled”). To be a well-behaved application on Windows you should default to the user’s My Documents folder (and of course use the correct APIs to find out where it is). Below the correct location should instead be “C:\Users\saveenr\Documents\PycharmProjects\untitled”.

image

We have some options for the kind of project to create. I just chose Empty project because I have no experience using Django or Google App Engine.

image

Once you click OK, you’ll notice that PyCharm is inspecting your environment.

snap0532

image

And finally the project is ready. Obviously not much going on there, which is appropriate because I did choose “Empty project” initially.

image

Examining the Project window will reveal that it discovered by “IronPython 2.6” (for .NET 2.0) installation but not my “IronPython 2.6 for .NET 4.0” installation nor my CPython 2.7 installation.

image

it’s not clear why a negative number shows as one of the nodes. I’ll assume this is just a bug.

image

Let’s add a file by right-clicking on the untitled node and selecting File/New

image

I gave it the name of “main.py”

image

No surprise, an empty python file is created.

image

I’ll paste in some IronPython code I wrote to automate Visio back in 2008.

The original blog post is here: http://blogs.msdn.com/saveenr/archive/2008/10/20/visio-automation-three-hello-world-samples-c-f-and-ironpython.aspx

The code is very simple but it will show how well PyCharm works with IronPython

import sys
import clr
import System
clr.AddReference("Microsoft.Office.Interop.Visio")
import Microsoft.Office.Interop.Visio
IVisio = Microsoft.Office.Interop.Visio
visapp = IVisio.ApplicationClass()
doc = visapp.Documents.Add("")
page = visapp.ActivePage
shape = page.DrawRectangle(1, 1, 5, 4)
shape.Text = "Hello World"

image

Running the Program

To run …

image

Which brought up this window that frankly surprised me

image

But it was clear that I simply had not selected “main.py” before I tried the run command. So I selected main.py and tried again…

image

image

 

Clicking on main …

image

Notice the new window at the bottom.

So the script ran and the correct thing happened – Visio was launched an a single rectangle was created with the text “Hello World”

image

Completion (“Intellisense”)

I had mixed results with completion in the editor.

image

image

image

I really wasn’t expecting it to work with objects created at runtime (“doc”, “shape”, “page”), but was hoping that PyCharm was going to do a little type inference to help out.

Parting Thoughts

  • I’ve been using SharpDevelop as my IronPython IDE, but I have to admit I’m impressed with PyCharm and will have to at least try using it for my next IronPython project.
  • While on the topic of SharpDevelop, another thing I noticed is that PyCharm’s UI responsiveness seems just slightly slower than what I’m used to with SharpDevelop or Visual Studio.
  • I still haven’t figured out how to make PyCharm use my other installations Python.