Question regarding the __kwdefaults__ output being None

Arup Rakshit ar at zeit.io
Fri Apr 19 08:07:38 EDT 2019


I have a very basic function.

def greet(name, msg = "Good morning!"):
   """
   This function greets to
   the person with the
   provided message.

   If message is not provided,
   it defaults to "Good
   morning!"
   """

   print("Hello",name + ', ' + msg)

Now when I am calling __kwdefaults__ on the function I am getting None.

3.7.3 (default, Mar 27 2019, 09:23:15) 
[Clang 10.0.1 (clang-1001.0.46.3)]
Python Type "help", "copyright", "credits" or "license" for more information.
from python_methods import greet
greet("Kate")
Hello Kate, Good morning!
greet("Bruce","How do you do?")
Hello Bruce, How do you do?
print(greet.__kwdefaults__)
None

What am I missing here? Should not I get {“msg”: “Good morning!”} ?


Thanks,

Arup Rakshit
ar at zeit.io






More information about the Python-list mailing list