Reputation: 1206
Say I have a function:
def test(ab):
print ab.a
print ab.b
How can I easily pass arguments to this function without defining a class? I'm looking for something along the lines of:
test({4,5})
or
test(ab.a = 5, ab.b = 6)
Is this at all possible? Changing the function 'test' is not an option.
Upvotes: 0
Views: 108
Reputation:
import collections
ab = collections.namedtuple("AB", "a b")(a=4, b=5)
test(ab)
Upvotes: 6