Last active
May 1, 2017 18:58
-
-
Save nvbn/51b1536dc05bddc09439f848461cef6a to your computer and use it in GitHub Desktop.
py-backwards result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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