I'm using the Python bindings to OpenCV. If I pass a nonexistent (or bad) file to cv.CaptureFromFile(), how do I test the return value for failure? In the C/C++ API, cvCaptureFromFile() returns NULL. In Python, I get: "<Capture (nil)>"

How do I test for "<Capture (nil)>"? 

```
capture = cv.CaptureFromFile( infilename )
# capture != None on failure so this doesn't work.
if capture is None :
    print "Unable to open \"{0}\"".format( infilename )
    sys.exit(1) 

```

I could use os.stat() but that wouldn't help with cases where the file exists but OpenCV genuinely cannot decode the file (e.g., codec error).