Skip to content

Instantly share code, notes, and snippets.

@nvbn
Last active May 1, 2017
Embed
What would you like to do?
py-backwards result
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
def _py_backwards_merge_dicts(dicts):
result = {}
for dict_ in dicts:
result.update(dict_)
return result
def returning_range(x):
_py_backwards_iterable_1 = iter(range(x))
while True:
try:
(yield next(_py_backwards_iterable_1))
except StopIteration as _py_backwards_exc_0:
break
_py_backwards_exc_4 = StopIteration()
_py_backwards_exc_4.value = x
raise _py_backwards_exc_4
def x_printer(x):
_py_backwards_iterable_3 = iter(returning_range(x))
while True:
try:
(yield next(_py_backwards_iterable_3))
except StopIteration as _py_backwards_exc_2:
if hasattr(_py_backwards_exc_2, 'value'):
val = _py_backwards_exc_2.value
break
print(''.join(['val ', '{}'.format(val)]))
def formatter(x):
items = (list(x_printer(x)) + [x]) # type: list
print(*(list(items) + list(items)))
return {'items': items}
result = _py_backwards_merge_dicts([{'x': 10}, dict(formatter(10))])
print(result)
class NumberManager(object):
def ten(self):
return 10
@classmethod
def eleven(cls):
return 11
class ImportantNumberManager(NumberManager):
def ten(self):
return super(ImportantNumberManager, self).ten()
@classmethod
def eleven(cls):
return super(ImportantNumberManager, cls).eleven()
print(ImportantNumberManager().ten())
print(ImportantNumberManager.eleven())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment