Skip to content

Instantly share code, notes, and snippets.

@ewxrjk
Last active October 1, 2017 09:29
Show Gist options
  • Save ewxrjk/f17d3f155efe028c5bd6e49e30023f04 to your computer and use it in GitHub Desktop.
Save ewxrjk/f17d3f155efe028c5bd6e49e30023f04 to your computer and use it in GitHub Desktop.
#! /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