Improved substitute function

git-svn-id: http://pyrap.googlecode.com/svn/trunk@351 80e5cd9e-5d28-0410-a7fc-3f808f404835