title: IOError: [Errno 2] No such file or directory Python
body: <p>I have this piece of code, trying to find <code>*.vm</code> files, and send them to another </p>
  
  <p>module i did, which supposed to read the lines.</p>
  
  <p>this is the main file:</p>
  
  <pre><code>def VMTranslte(fileName):
  print "FILEOVER ",fileName
  from parser import Parser
  from codeWriter import CodeWriter
  if (fileName[-3:] == ".vm"):
      outputFile = fileName[:-3]+".asm"
      myWrite = CodeWriter(outputFile)
      myWrite.setFileName(fileName)
      myParser = Parser(fileName)
      myWrite.setFileName(fileName);
      translate(myParser,myWrite)
  else:
      if fileName[-1:] == "/": &lt;===== CHECKS FOR DIRECTORY
          mystr = fileName.split('/')[-2]
          mystr = mystr.split('.')[0]+".asm"
          outputFile = fileName+mystr
      else:
          outputFile = fileName+".asm"
      myWrite = CodeWriter(outputFile)
      for child in os.listdir(fileName):
          if child.endswith('.vm'): &lt;===== CHECK IF THERE IS *.vm FILE
              print "CHILD: ",child &lt;===== PRINTS THE FILE WANTED (MEANING FINDS IT)
              myWrite.setFileName(child);
              myParser = Parser(child) &lt;===== CALLS THE READER MODULE DESCRIBED AT THE BOTTOM
              translate(myParser,myWrite) 
  myWrite.close()
  </code></pre>
  
  <p>the module which supposed to read the lines:</p>
  
  <pre><code>#Constructor for Parser module.
  def __init__(self,fileName):
      import re
      self.cmds = []
      self.counter = 0
      myFile = open(fileName, 'r') &lt;=====ERROR OVER HERE
      fLines = myFile.readlines()
      for value in fLines : 
          lineStrip = value.strip()
          if not (re.match("//",lineStrip) or len(lineStrip)==0):
              self.cmds.append(lineStrip)
  </code></pre>
  
  <p>the error is:</p>
  
  <pre><code>  File "/Users/***/Desktop/dProj7/parser.py", line 19, in __init__
    myFile = open(fileName, 'r')
    IOError: [Errno 2] No such file or directory: 'BasicTest.vm'
  </code></pre>
  
  <p>it is clear that the script finds the file, (he goes in the first loop),</p>
  
  <p>what is going on over here?</p>