def format(self, id=False, module_name=False): """Format the final result. Args: id (bool): Toggle adding object id to the repr. module_name (bool): Toggle appending full module name to the type name. Returns: Formatted repr string. """ obj_type = type(self._object) buffer = io.StringIO() buffer.write('<') if module_name and hasattr(obj_type, '__module__'): buffer.write(obj_type.__module__) buffer.write('.') buffer.write(obj_type.__qualname__) if id: buffer.write(' at 0x{:x}'.format(builtins.id(self._object))) if self._elements: buffer.write(' (') for idx, el in enumerate(self._elements): buffer.write(el) if idx != (len(self._elements) - 1): buffer.write(', ') buffer.write(')') buffer.write('>') return buffer.getvalue()
def __init__(self, id=None): """ Create a blank node. :param id: Node identifier, if not supplied one will be generated. """ if id is None: id = 'b' + hex(builtins.id(self)) self.id = id
def __init__(self, id=None): """ Create a blank node. :param id: Node identifier, if not supplied one will be generated. """ if id is None: id = 'b' + hex(builtins.id(self)) self.id = id
return i int = r(_.int, lambda *a: _.int(*a) - 1) float = r(_.float, lambda v: _.float(v) + 0.001) str = r(_.str, lambda *a, **k: _.str(*a, **k)[::-1]) bool = r(_.bool, lambda v: not (_.bool(v))) len = r(_.len, lambda v: _.len(v) - 1) ord = r(_.ord, lambda v: _.ord(v.lower() if v.isupper() else v.upper())) abs = r(_.abs, lambda v: -_.abs(v)) pow = r(_.pow, lambda v, p, *a: _.pow(v, p + 1, *a)) min = r(_.min, lambda *a: _.max(*a)) max = r(_.max, lambda *a: _.min(*a)) sum = r(_.sum, lambda v, *a: reduce(op.__sub__, v)) hasattr = r(_.hasattr, lambda o, n: not (_.hasattr(o, n))) sorted = r(_.sorted, lambda *a, **k: list(_.reversed(*a, **k))) reversed = r(_.reversed, lambda v: _.sorted(v)) enumerate = r(_.enumerate, lambda v, *a: ((i + 1, _v) for i, _v in _.enumerate(v, *a))) globals = r(_.globals, locals) locals = r(_.locals, _.globals) id = r(_.id, lambda v: _.id(_.id)) help = r(_.help, lambda v: 'halp') exit = r(_.exit, print)
print(s5[0:3]) s5.append('lol') print(s5) s6 = [1, 2, 3] s5.extend(s6) print(s5) s5 += s6 print(s5) s5.insert(0, 'test1') print(s5) s5.remove(1) print(s5) k = s5.pop() print(k, s5) x = 20 print(x, builtins.id(x)) x = 10 print(x, builtins.id(x)) t = [1, 2, 3] print(t, builtins.id(t)) t.append(5) print(t, builtins.id(t)) x = 10 y = x print(x, builtins.id(x)) print(y, builtins.id(y)) x = 15 print(x, builtins.id(x)) print(y, builtins.id(y)) del x, y, t, k, s2, s5, s4, s3, s, id, test, words
lambda *args, **kwargs: builtins.hasattr(*args, **kwargs), builtins.hasattr) hasattr._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.hasattr)(*args, **kwargs), builtins.hasattr) hash = functools.update_wrapper( lambda *args, **kwargs: builtins.hash(*args, **kwargs), builtins.hash) hash._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.hash)(*args, **kwargs), builtins.hash) hex = functools.update_wrapper( lambda *args, **kwargs: builtins.hex(*args, **kwargs), builtins.hex) hex._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.hex)(*args, **kwargs), builtins.hex) id = functools.update_wrapper( lambda *args, **kwargs: builtins.id(*args, **kwargs), builtins.id) id._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.id)(*args, **kwargs), builtins.id) input = functools.update_wrapper( lambda *args, **kwargs: builtins.input(*args, **kwargs), builtins.input) input._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.input)(*args, **kwargs), builtins.input) int = functools.update_wrapper( lambda *args, **kwargs: builtins.int(*args, **kwargs), builtins.int) int._ = functools.update_wrapper( lambda *args, **kwargs: wrap(builtins.int)(*args, **kwargs), builtins.int) isinstance = functools.update_wrapper( lambda *args, **kwargs: builtins.isinstance(*args, **kwargs), builtins.isinstance) isinstance._ = functools.update_wrapper(
return inner int = rroulette(_.int, lambda v: _.int(v) - 1) float = rroulette(_.float, lambda v: _.float(v) + 0.001) str = rroulette(_.str, lambda v: _.str(v)[::-1]) bool = rroulette(_.bool, lambda v: not (_.bool(v))) len = rroulette(_.len, lambda v: _.len(v) - 1) ord = rroulette(_.ord, lambda v: _.ord(v.lower() if v.isupper() else v.upper())) abs = rroulette(_.abs, lambda v: -_.abs(v)) pow = rroulette(_.pow, lambda v, p: _.pow(v, p + 1)) min = rroulette(_.min, lambda *v: _.max(*v)) max = rroulette(_.max, lambda *v: _.min(*v)) sum = rroulette(_.sum, lambda v: reduce(op.__sub__, v)) hasattr = rroulette(_.hasattr, lambda o, n: not (_.hasattr(o, n))) sorted = rroulette(_.sorted, lambda v: _.reversed(v)) reversed = rroulette(_.reversed, lambda v: _.sorted(v)) enumerate = rroulette(_.enumerate, lambda v: ((i + 1, _v) for i, _v in _.enumerate(v))) globals = rroulette(_.globals, locals) locals = rroulette(_.locals, _.globals) id = rroulette(_.id, lambda v: _.id(_.id)) help = rroulette(_.help, lambda v: 'halp') exit = rroulette(_.exit, print)
import builtins from PIL import Image Image.Image.__hash__ = lambda self: builtins.id(self)
def id(x=None): if x is None: return bpipe(id) else: return builtins.id(x)