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

All Samples(5)  |  Call(0)  |  Derive(0)  |  Import(5)
bool(x) -> bool

Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.

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,
    ast.Add, ast.Sub,
    ast.Mult, ast.Div)
if PYTHON2:
    COMPLEX_BINOPS += (ast.FloorDiv, ast.Mod)
 
    def check_format_args(self, format, values):
        if PYTHON2:
            if isinstance(format, BYTES_TYPE):
                if is_bytes_ascii(format):
                    return True
            return self.string_format(node, left_cst, right_cst)
 
        if (PYTHON2
        and isinstance(node.op, ast.Div)
        and (isinstance(left_cst, INT_TYPES)
                return new_node
 
    if PYTHON2:
        def visit_Print(self, node):
            if not node.values:

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,
    return (result <= config.max_size)
 
if PYTHON2:
    def check_str_args(config, args):
        arg = args[0]
    config.add_func('sum', Function(sum, (1, 2), (tuple, frozenset), COMPLEX_TYPES, check_args=check_sum_args))
 
    if PYTHON2:
        config.add_func('long', Function(long, 1, FLOAT_TYPES))
        config.add_func('unichr', Function(unichr, 1, INT_TYPES, check_args=check_unichr))

src/a/s/astoptimizer-0.6/astoptimizer/config_string.py   astoptimizer(Download)
"""
Enable optimizations on the string module.
"""
from astoptimizer.compatibility import (
    PYTHON2, PYTHON3,
        'digits', 'hexdigits', 'octdigits',
        'printable', 'punctuation', 'whitespace')
    if PYTHON2:
        CONSTANTS += ('letters', 'lowercase', 'uppercase')
    for name in CONSTANTS:
        # on Python2, capwords() is locale dependent
        config.add_func('string.capwords', Function(string.capwords, 1, NATIVE_STR))
    if PYTHON2:
        config.add_func('string.atof', Function(string.atof, 1, STR_TYPES, catch=ValueError))
        config.add_func('string.atoi', Function(string.atoi, (1, 2), STR_TYPES, INT_TYPES, catch=ValueError))

src/a/s/astoptimizer-0.6/astoptimizer/config_platform.py   astoptimizer(Download)
import sys
from astoptimizer.config import Function
from astoptimizer.compatibility import PYTHON2, INT_TYPES, PYTHON34
if PYTHON34:
    import enum
    config.add_constant('sys.byteorder', sys.byteorder)
    config.add_constant('sys.platform', sys.platform)
    if PYTHON2:
        config.add_constant('sys.maxint', sys.maxint)
    config.add_constant('sys.maxsize', sys.maxsize)

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,
        self.check('%r %% 123' % u("x=%s"), self.text_unicode(u('x=123')))
        self.check('%r %% (2, 3)' % u("x=%s y=%s"), self.text_unicode(u('x=2 y=3')))
        if PYTHON2:
            self.check('"x=%s" % 123',
                       self.text_bytes(b('x=123')))
            warning='Optimization missed because the builtin list is shadowed')
 
        if PYTHON2:
            self.check(
                'from math import pow as list; [x for x in range(1000)]',
        self.check_not_optimized('for x in tuple(iterable): print(x)', config)
        self.check_not_optimized('for x in list(iterable): print(x)', config)
        if PYTHON2:
            self.check('for x in range(1000): print(x)',
                       self.text_ast('for x in xrange(1000): print(x)'),
        self.check('(x*2 for x in "")',
                   self.text_ast('(None for x in ())'))
        if PYTHON2:
            self.check('(x*2 for x in range(1000))',
                       self.text_ast('(x*2 for x in xrange(1000))'),