Exemplo n.º 1
0
def str_repeat(args):
    string = args[0]
    repeat = args[1]
    assert(isstr(string))
    assert(isint(repeat))
    repeated = string.str() * repeat.get_int()
    return W_StringObject(repeated)
Exemplo n.º 2
0
def str_repeat(interpreter, space, args):
    string = args[0].get_value()
    repeat = args[1].get_value()
    assert(isstr(string))
    assert(isint(repeat))
    repeated = string.str() * repeat.get_int()
    return space.wrap(repeated)
Exemplo n.º 3
0
def printf(interpreter, space, args):
    template = args[0]
    assert(isstr(template))
    items = [arg.get_value() for arg in args[1:]]
    formatter = StringFormatter(template.str(), items)
    interpreter.output(formatter.format())
    return space.w_Null
Exemplo n.º 4
0
def printf(space, args):
    template = args[0]
    assert(isstr(template))
    items = [arg.get_value() for arg in args[1:]]
    formatter = StringFormatter(template.str(), items)
    printf_(formatter.format())
    return w_Null
Exemplo n.º 5
0
def str_repeat(space, args):
    string = args[0].get_value()
    repeat = args[1].get_value()
    assert(isstr(string))
    assert(isint(repeat))
    repeated = string.str() * repeat.get_int()
    return newstring(repeated)
Exemplo n.º 6
0
def define(interpreter, space, args):
    name = args[0].get_value()
    assert(isstr(name))
    value = args[1].get_value()

    if space.get_constant(name.str()):
        return space.w_False

    space.declare_constant(name.str(), value)
    return space.w_True
Exemplo n.º 7
0
def strlen(args):
    string = args[0]
    assert(isstr(string))
    return W_IntObject(string.len())
Exemplo n.º 8
0
def strlen(interpreter, space, args):
    string = args[0].get_value()
    assert(isstr(string))
    return space.wrap(string.len())
Exemplo n.º 9
0
def strlen(space, args):
    string = args[0].get_value()
    assert(isstr(string))
    return newint(string.len())
Exemplo n.º 10
0
def define(space, args):
    name = args[0].get_value()
    assert(isstr(name))
    value = args[1].get_value()
    return newbool(space.declare_constant(name.str(), value))