If you're sure that the value of img is None in your case, you can simply use if not img is None, or, equivalently, if img is not None. You don't need to check the type explicitly.
Note that None and False are not the same value. However, bool(None)==False, which is why if None fails.
The documentation for imread, both for OpenCV 2 and 3, states, however, that a empty matrix should be returned on error. You can check for that using if img.size ==0
python - cv2.imread: checking if image is being read - Stack Overflow
python - I am reading an image with cv2.imread(), and converting it to grayscale. However why is it not in grayscale when I display it? - Stack Overflow
python - The image read by cv2.imread() in the current folder is always None, and the image under the current file does not contain a Chinese path - Stack Overflow
OpenCV with media object cv2.imread() error
If you're sure that the value of img is None in your case, you can simply use if not img is None, or, equivalently, if img is not None. You don't need to check the type explicitly.
Note that None and False are not the same value. However, bool(None)==False, which is why if None fails.
The documentation for imread, both for OpenCV 2 and 3, states, however, that a empty matrix should be returned on error. You can check for that using if img.size ==0
If you want to write the contents as soon as the image file is being generated then you can use os.path.isfile() which return a bool value depending upon the presence of a file in the given directory.
import cv2
import os.path
while not os.path.isfile("myImage.jpg"):
#ignore if no such file is present.
pass
img = cv2.imread("myImage.jpg", 0)
cv2.imwrite("result.jpg", img)
You can also refer to docs for detailed implementation of each method and basic image operations.
import cv2
img=cv2.imread("colorful.png",1)
cv2.imshow("",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Result:

import cv2
img=cv2.imread("colorful.png",0) # same image changed the 1 to 0
cv2.imshow("",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Result:

Conclusion
As I said in a comment maybe the image you used is causing the no grayscale.
I do not really know but try using that: cv2.imread("path", cv2.IMREAD_GRAYSCALE).
PS. And it is better to use sys.path.join() instead of raw /
I'm using Windows 10 with Python 3.6, my opencv-python cannot read image unless directly input in the same folder.
cv2.imread('C:\folder\image.png')
cv2.imread('C:\folder\image.png', 0)
cv2.imread('C:/folder/image.png')
cv2.imread(r'C:/folder/image.png')
cv2.imread('C://folder//image.png')
cv2.imread('C:\\folder\\image.png')
All tried, but all returned None.
Now I could only read image by
cv2.imread('image.png')
Which I saved image in the same folder.
How could I read by cv2.imread()?