2009-12-27

Using CPython modules from IronPython

I have IronPython 2.6 and Python 2.6.4 installed on a Windows box.

IronPython's interpreter ipy.exe is not installed on a directory on path, just unzipped in an arbitrary folder.
Python 2.6.4 is installed in C:\Python26 directory.

You can import pure CPython modules from IronPython as follows:

C:\Users\dude\Documents\SharpDevelop Projects\Faman5>ipy
IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4927
Type "help", "copyright", "credits" or "license" for more information.
>>> # Try to import the os module.
>>> import os
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named os
>>> # OK, we are sure that the module is can not be imported.
>>> # Now we need to import the sys module to achive our goal.
>>> import sys
>>> # sys.path is the list of directories to look for when importing modules.
>>> sys.path
['.', '.', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5\\Lib', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5\\DLLs', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5']
>>> # Add the Cpython path to the sys.path as follows:
>>> sys.path.append("C:\Python26\Lib")
>>> sys.path
['.', '.', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5\\Lib', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5\\DLLs', 'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5', 'C:\\Python26\\Lib']
>>> # Now we are sure that 'C:\\Python26\\Lib' is added.
>>> # Let us try to import the os module again.
>>> import os
>>> os.getcwd()
'C:\\Users\\dude\\Documents\\SharpDevelop Projects\\Faman5'
>>> # Success!

2009-12-03

SNMP OID translator plugin for Vim

I have written an SNMP OID translator plugin for Vim.
By using this plugin, one can translate OIDs directly within Vim without exiting from the editor.
I find it useful for discovering the MIB files, and translating while reading them.

Note that you have to have Net-SNMP installed on your system.
http://www.net-snmp.org/

You can see the detais and download the plugin from the following link:

http://www.vim.org/scripts/script.php?script_id=2881


Here is a screenshot of the plugin.

FORTRAN valid line length plugin for Vim

I have written a Vim plugin to help my FORTRAN coding in Vim.

According to the file extension of a FORTRAN source file, this plugin sets a valid line length. Any characters occurring after this column are considered as error, and are matched so by highlighting.

This plugin is run automatically. But, if you want to use any other valid size for some reason, the commands are available.

You can download the plugin from the following link.
http://www.vim.org/scripts/script.php?script_id=2868

The following commands are available after installing this plugin.

:FORTRANLengthAccordingToExtension
Sets the valid line length according to the file extension.
This command is applied by default.
:FORTRANStandardLength72
The columns occurring after the 72nd character are marked.
:FORTRANCardImageLength80
The columns occurring after the 80th character are marked.
:FORTRANExtendedLength132
The columns occurring after the 132nd character are marked.
:FORTRANRemoveMatching
Removes the matching set by this plugin.

Here is the screenshot of the plugin. (Colorscheme is Molokai).