The answers at Can I determine the number of channels in cv::Mat Opencv answer this question for OpenCV 1: you use the Mat.channels() method of the image.
Mat.channels()
As i know, u should use image.shape[2] to determine number of channels, not len(img.shape), the latter gives the dimensions of the array.