os.walk works with non-escaped backslash?
<p>Just found a bug in a bit of code I was writing that wasn't actually bugging?</p>

<pre><code>for folderName, subfolders, filenames in os.walk('C:\FOLDER'):
print('The current folder is ' + folderName)
for subfolder in subfolders:
    print('SUBFOLDER OF ' + folderName + ': ' + subfolder)
for filename in filenames:
    print('FILE INSIDE ' + folderName + ': '+ filename)
</code></pre>

<p>and</p>

<pre><code>for folderName, subfolders, filenames in os.walk('C:\\FOLDER'):
print('The current folder is ' + folderName)
for subfolder in subfolders:
    print('SUBFOLDER OF ' + folderName + ': ' + subfolder)
for filename in filenames:
    print('FILE INSIDE ' + folderName + ': '+ filename)
</code></pre>

<p>both work in shell and the full code runs fine? Shouldn't that first one be stuffing up because it is feeding it 'C:OLDER'?</p>

<p>Python ignores unrecognised escape sequences and leaves the original backslash and letter in place.</p>

<p><code>\F</code> is not a valid escape sequence, so your string contains a literal <code>\</code> backslash followed by a literal <code>F</code>:</p>

<pre><code>&gt;&gt;&gt; 'C:\FOLDER'
'C:\\FOLDER'
</code></pre>

python python-3.x