Python PDF module and Visual Studio
<p>I'm teaching myself Python thanks to a book and nice people i find every day in SO. Thanks all of you.</p>

<p>The question is that i been using VS, because i find it easy, but idk how/where to write commands like "python pythonprogram.py" and make use of the optparse module as i do on a Linux console.</p>

<p>The program i'm working on extracts the metadata from a pdf and it's the code below. </p>

<pre><code>import PyPDF2
import optparse

def printMeta(fileName):

pdfFile = pdfFileReader(file(fileName, 'rb'))
docInfo = pdfFile.getDocumentInfo()
print('[*] PDF Metadata For: ' + str(fileName))

for metaItem in docInfo:
    print('[+]' + metaItem + ':' + docInfo[metaItem])

def main():

parser = optparse.OptionParser('usage %prog' + '-F &lt;PDF File Name&gt;')
parser.add_option('-F', dest='fileName', type='string', help='specify PDF file Name')
(options, args) = parser.parse_args()
fileName = options.fileName

if fileName == None:
    print(parser.usage)
    exit(0)
else:
    printMeta(fileName)

if __name__ == '__main__':     
fileName = 'pdftest.pdf'
main()
</code></pre>

<p>This is a double question, one about VS proper use and the other to ask if my code works. I want to say that the pdftest.pdf is in the python program folder so i don't need a direction if i'm right. Thanks  </p>

<p>To make sure where your relative path starts, you might want to use <code>os.chdir</code></p>

<pre><code>from os import chdir
chdir("path/to/my/python/file")
</code></pre>

<p>then, you'll be able to import files in the same directory even if you're running the script from another folder.</p>

<p>Hope that helps</p>

python visual-studio python-3.x pdf