Last active
October 1, 2017 09:29
-
-
Save ewxrjk/f17d3f155efe028c5bd6e49e30023f04 to your computer and use it in GitHub Desktop.
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
#! /usr/bin/python3 | |
class P(list): | |
def __call__(self, *args, **kwargs): | |
return [lv(*args, **kwargs) for lv in self] | |
def __getattr__(self, name): | |
return P([getattr(lv, name) for lv in self]) | |
class F(object): | |
def __init__(self, n): | |
self.formatted="%05s" % n | |
print(P([F(1),F(10),F(100),F(1000)]).formatted) | |
print(P([1,2,4,8]).bit_length()) | |
# Outputs: | |
# [' 1', ' 10', ' 100', ' 1000'] | |
# [1, 2, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment