Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# -*- coding: utf-8 -*-
class MyList(list):
def __init__(self, items, more):
# modify items here
new_items = map(lambda x: x + '_hi', items)
super(MyList, self).__init__(new_items)
# assign rest here
self.more = more
my_list = MyList(['a', 'b', 'c'], 'stuff')
assert my_list == ['a_hi', 'b_hi', 'c_hi']
assert my_list.more == 'stuff'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment