repr on a string

Alexander Schmolck a.schmolck at gmx.net
Mon Jun 2 14:45:24 EDT 2003


"Terry Reedy" <tjreedy at udel.edu> writes:

> "Alexander Schmolck" <a.schmolck at gmx.net> wrote in message
> news:yfswug4yeka.fsf at black132.ex.ac.uk...
> > David Shochat <shochatd at yahoo.com> writes:
> > > for dir in sys.path:
> > >     if string.find(os.path.abspath(dir), 'PyTools') != -1:
> > >         print 'removing', repr(dir)
> > >         sys.path.remove(dir)
> > >
> > > In the 3d line, why does he not just say:
> > >   print 'removing', dir
> 
> > My guess would be: mainly to put the name into (the right; ' or ")
> quotation
> > marks and make sure that funny characters are escaped. I think using
> `str`
> > here would be equally OK, although then the user wouldn't be able to
> tell
> > apart e.g. "that filename " from "that filename".
> 
> Instead of asking or guessing, one can try things out in the
> interactive interpreter:

Great -- what command do I have to type into my interactive interpreter to
divine programmer intent?

'as




More information about the Python-list mailing list