[IPython-user] auto-quote broke and fix

Fernando Perez Fernando.Perez at colorado.edu
Fri May 13 00:33:19 CDT 2005


Jerry McRae wrote:
> Hi,
> 
> I just starting using IPython and somehow got 0.6.5.  When I went to
> the home page I found and downloaded 0.6.13.  I then noticed the
> auto-quote function ( ,ord a --> ord('a') ) no longer worked.  I liked
> that!  Since it worked before, I figured I could see what changed.
> And since I saw no messages or entries in the bug tracking for it,
> maybe I could find a solution.
> 
> Well, that took a bit of searching for a newbie, but I found and fixed
> the , and / prefix, and while I was in there mucking around, and added
> a ; to quote the whole command, I.E
> ;runcommand this is a test  ==> runcommand("this is a test")
> 
> #####
> Changes to fix , prefix:
> 1799> if pre == self.ESC_QUOTE:
>          ^
>          iFun[0]
> and add [1:] to iFun two lines down
> 
> #####
> Changes to fix / prefix:
> before 1811> if theRest.endswith.....
> added: if iFun[0] == self.ESC_PAREN: iFun = iFun[1:]
> 
> #####
> additions for ; prefix:
> just after the block at 1799 I added:
>         elif iFun[0] == self.ESC_1QUOTE:
>             # Auto-quote whole string
>             newcmd = '%s("%s")\n' % (iFun[1:],theRest)
> 
> I then Defined and added ESC_1QUOTE to esc_handlers.  I hope this
> helps others who missed that function.

Thanks for this, sorry for the delay in replying.  The proper fix is actually 
a bit different, but you couldn't have known that (it should be done in a 
deeply buried regexp ipython uses for input line analysis).  Good detective work!

And I added your ; whole-line quoting as well, since it does no harm and can 
be  useful on occasion.  Thanks for the contribution!  All this will go into 
the .14 bugfix, which I'll have to put out because of this (and other) small 
problems which people reported with .13.

Regards,

f




More information about the IPython-user mailing list