cStringIO code example
Example: python import stringIO
try:
from StringIO import StringIO ## for Python 2
except ImportError:
from io import StringIO ## for Python 3
try:
from StringIO import StringIO ## for Python 2
except ImportError:
from io import StringIO ## for Python 3