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)
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)
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
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
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)
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
def strlen(args): string = args[0] assert(isstr(string)) return W_IntObject(string.len())
def strlen(interpreter, space, args): string = args[0].get_value() assert(isstr(string)) return space.wrap(string.len())
def strlen(space, args): string = args[0].get_value() assert(isstr(string)) return newint(string.len())
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))