[Tutor] *args, **kwargs

Luis N tegmine at gmail.com
Sat Jan 1 22:19:45 CET 2005


Hi,

I gave this a quick read: http://aspn.activestate.com/ASPN/Mail/Message/573292

I'm wondering how I can turn a variable number of keyword arguments
passed to a class into variables for use in said class:

#This so doesn't work

class SomethingLikeThis:
    def __init__(self, **kwargs):
        self.kwargs = kwargs

    def show(self):
        for k in self.kwargs.keys():
            v = selfkwargs.get(k)
            print v

I'm probably misunderstanding the purpose of *args and **kwargs totally.


More information about the Tutor mailing list