class hoge:
_items = []
_def each(self,callback=None):
__res=[]
___argcount=callback.__code__.co_argcount
__if _argcount==1:
___for item in self.items:
____res.append(callback(item))
__elif _argcount==2:
___for i,item in enumerate(self.items):
____res.append(callback(i,item))
__return res

h=hoge()
h.items = ["a","b","c"]
print( h.each(lambda item: "_"+str(item)) )
print( h.each(lambda i,item: str(i)+"_"+str(item)) )
#['_a', '_b', '_c']
#['0_a', '1_b', '2_c']

callbackでindexも取りたいので↑のように書いたのですが
こうするしかないのでしょうか?
今は引数は、(item)と(i,item)しかとりませんが
仮にcallback内でitemやindexとは別の何か引数を引き継ぎたくなったという場合
どう拡張していけばいいのかな、と思いました