Python - issues with numbers in pathnames
<p>I need to open all PDFs in a certain directory, so I first generate a list of the file paths using os.path:</p>

<pre><code>filenames = [
    normpath(join(directoryname, filename))
    for filename in listdir(directoryname)
    if filename.lower().endswith('.'+extension)            
    ]
</code></pre>

<p>So an item in that list looks like this:
D:\\Folder\\2010\\file.pdf</p>

<p>Then I'd like to open each file in a for-loop:</p>

<pre><code>for file in filenames:
    PdfFileReader(file(file, 'rb'))
</code></pre>

<p>but there seems to be an issue with the 2010, because I get this error:</p>

<pre><code>IOError: [Errno 2] No such file or directory: 'D:\\Folder\\x810\\file.pdf'
</code></pre>

<p>I'd like to do something along the lines of</p>

<pre><code>PdfFileReader(file(r'D:\\Folder\\2010\\file.pdf', 'rb'))
</code></pre>

<p>how would I do that in the above example where the path is passed as a variable?
Or are there any better ways to do this?</p>

<p>I'm using Windows and Python 2.6.</p>

<p>Thanks in advance!</p>
