2

I think following code should print a\n('b')\n{'a':1}. But, actually it print "a\n('b', {'a': 1})\n{}" Why? I checked these discussions and seems my code does not have problems.

class Parent(object):
    def f(self, a, *args, **kwargs):
        print a
        print args
        print kwargs

class Child(Parent):
    def f(self, a, *args, **kwargs):
        super(Child, self).f(a, *args, **kwargs)

c = Child()
c.f("a", "b", {"a":1})
Community
  • 1
  • 1
Light Yagmi
  • 5,085
  • 12
  • 43
  • 64

1 Answers1

1

This is the expected output. You seem to think that your dictionary should be treated as a keyword argument. It's not, it's also a positional argument like b.

A keyword argument akw would be called like this:

 f("a", "b", akw=1):
      # your code
DevShark
  • 8,558
  • 9
  • 32
  • 56