[IPython-dev] Patch for paren completion glitch

Fernando Perez Fernando.Perez at colorado.edu
Thu Jul 22 09:44:23 CDT 2004


Fernando Perez wrote:

> and I'd like to keep it that way.  In particular, I think that
> 
> def unprotect_filename(s):
>      chs = []
>      in_escape = False
>      for ch in s:
>          if in_escape:
>              chs.append(ch)
>              in_escape = False
>              continue
>          if ch == '\\':
>              in_escape = True
>              continue
>          chs.append(ch)
> 
>      return "".join(chs)
> 
> is essentially:
> 
> # Alternative unprotect_filename
> # About 5 times faster than the original
> unprotect_filename2 = lambda s:s.replace('\\','')
> 
> Am I right?  If that's the case, it can (and should) be explicitly inlined, 

Ok, I just realized that they are NOT the same when the input has several 
contiguous '\' in it.  Is this kind of filename realistic though?  Are there 
any valid filenames where the two alternatives differ?

cheers,

f




More information about the IPython-dev mailing list