Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
Convert `obj` to (unicode) text string

        def to_text_string(obj, encoding=None):
    """Convert `obj` to (unicode) text string"""
    if PY2:
        # Python 2
        if encoding is None:
            return unicode(obj)
        else:
            return unicode(obj, encoding)
    else:
        # Python 3
        if encoding is None:
            return str(obj)
        elif isinstance(obj, str):
            # In case this function is not used properly, this could happen
            return obj
        else:
            return str(obj, encoding)
        


src/s/a/Satellite-0.8.dev/satellitelib/qt/compat.py   Satellite(Download)
from .QtGui import QFileDialog
 
from .py3compat import is_text_string, to_text_string, TEXT_TYPES
 
#==============================================================================
    if not is_text_string(result):
        # PyQt API #1
        result = to_text_string(result)
    return result
 
    if QString is not None:
        # PyQt API #1: conversions needed from QString/QStringList
        selectedfilter = to_text_string(selectedfilter)
        if isinstance(output, QString):
            # Single filename
            output = to_text_string(output)
        else:
            # List of filenames
            output = [to_text_string(fname) for fname in output]