Show mapped drives

Introduction

What drives do I have mapped? This is the same as running NET USE at the command line. There is an appropriate Win32 API which the pywin32 extensions wrap in the win32net module.

from __future__ import generators
import win32net
resume = 0
while 1:
  (_drives, total, resume) = win32net.NetUseEnum (None, 0, resume)
  for drive in _drives:
    if drive['local']:
      print drive['local'], "=>", drive['remote']
  if not resume: break