title: with os.scandir() raises AttributeError: __exit__
body: <p>An <code>AttributeError</code> is raised when I use the example code from python's documentation (<a href="https://docs.python.org/3/library/os.html#os.scandir" rel="noreferrer">here</a>). The example code is as follows:</p>
  
  <pre><code>with os.scandir(path) as it:
      for entry in it:
          if not entry.name.startswith('.') and entry.is_file():
              print(entry.name)
  </code></pre>
  
  <p>The result is an <code>AttributeError</code>:</p>
  
  <pre><code>D:\Programming&gt;test.py
  Traceback (most recent call last):
    File "D:\Programming\test.py", line 3, in &lt;module&gt;
      with os.scandir() as it:
  AttributeError: __exit__
  </code></pre>
  
  <p>Although, assigning <code>os.scandir()</code> to a variable works fine.
  Could someone tell me what I'm missing?</p>