Eliminate "extra" variable

Chris Angelico rosuav at gmail.com
Sun Dec 15 21:57:24 EST 2013


On Mon, Dec 16, 2013 at 1:43 PM, Igor Korot <ikorot01 at gmail.com> wrote:
> So, how do I convert my string to one of those?
> I realized I can just do replace '/' to '\', but is there a better alternative?

The path is exactly the same, whether you use forward slashes or
backslashes, on Windows. Most of the world uses backslashes for
Windows paths, but forward slashes do work fine (and that's not a
Python thing - the underlying APIs work with / just fine too). So you
don't have to actually replace anything.

>>> len(open("c:/Festival2013.txt").read())
79137

ChrisA



More information about the Python-list mailing list