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

All Samples(5)  |  Call(0)  |  Derive(0)  |  Import(5)
str(object='') -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

src/a/s/astoptimizer-0.6/astoptimizer/optimizer.py   astoptimizer(Download)
    clone_node_list, is_empty_body)
from astoptimizer.config import optimize_unicode
from astoptimizer.compatibility import (
    u,
    PYTHON2, PYTHON27, PYTHON3, PYTHON33, PYTHON34,
    def check_format_args(self, format, values):
        if PYTHON2:
            if isinstance(format, BYTES_TYPE):
                if is_bytes_ascii(format):
                    return True
            elif isinstance(format, UNICODE_TYPE):
                return all(
                    (not isinstance(value, BYTES_TYPE)) or is_bytes_ascii(value)
                    for value in values)
        else:
            # Python 3
            return all(not isinstance(value, BYTES_TYPE) for value in values)
    def binop(self, node, eval_binop, left, left_cst, right, right_cst):
        if (isinstance(node.op, ast.Mod)
        and isinstance(left_cst, STR_TYPES)):
            # str % args
            if PYTHON3 and isinstance(left_cst, BYTES_TYPE):

src/a/s/astoptimizer-0.6/astoptimizer/config_builtin_funcs.py   astoptimizer(Download)
"""
Enable optimizations on the builtins functions, example: len().
"""
from astoptimizer.compatibility import (
    is_bytes_ascii, is_unicode_ascii,
    def check_unicode_args(config, args):
        arg = args[0]
        if isinstance(arg, BYTES_TYPE):
            return is_bytes_ascii(arg)
        else:

src/a/s/astoptimizer-0.6/astoptimizer/config_builtin_types.py   astoptimizer(Download)
"""
Enable optimizations on the builtins types, example: unicode.encode().
"""
 
from astoptimizer.compatibility import (
def setup_config(config):
    # bytes, str, unicode
    config.add_method(Method(BYTES_TYPE, 'decode', (1, 2), NATIVE_STR, NATIVE_STR, check_args=check_str_decode_args))
    config.add_method(Method(UNICODE_TYPE, 'encode', (1, 2), NATIVE_STR, NATIVE_STR, check_args=check_str_encode_args))
    for str_type in STR_TYPES:
        config.add_method(Method(str_type, 'rpartition', 1, str_type))
 
        if PYTHON3 and str_type == BYTES_TYPE:
            config.add_method(Method(str_type, 'join', 1, (tuple, frozenset), check_args=check_str_join))
        else:

src/a/s/astoptimizer-0.6/astoptimizer/ast_tools.py   astoptimizer(Download)
import ast
from astoptimizer.compatibility import (
    PYTHON3, COMPLEX_TYPES, BYTES_TYPE, UNICODE_TYPE)
import sys
import copy
        else:
            new_node = ast.Str(s=value)
    elif isinstance(value, BYTES_TYPE):
        if PYTHON3:
            new_node = ast.Bytes(s=value)
        if all(isinstance(elt, UNICODE_TYPE) for elt in value):
            arg = new_constant(node, UNICODE_TYPE().join(sorted(value)))
        elif all(isinstance(elt, BYTES_TYPE) for elt in value):
            arg = new_constant(node, BYTES_TYPE().join(sorted(value)))
        else:

src/a/s/astoptimizer-0.6/astoptimizer/tests.py   astoptimizer(Download)
 
from astoptimizer import Config as _Config, parse_ast, compile_ast
from astoptimizer.compatibility import (
    PYTHON2, PYTHON27, PYTHON3, PYTHON34,
    u, b,
        def _text_bytes(self, value):
            assert isinstance(value, BYTES_TYPE)
            return "Str(s=%r)" % value
        def _text_unicode(self, value):
            assert isinstance(value, UNICODE_TYPE)
        elif isinstance(value, (int, float, complex)):
            return self._text_num(value)
        elif isinstance(value, BYTES_TYPE):
            return self._text_bytes(value)
        elif isinstance(value, UNICODE_TYPE):