DesktopDev
DesktopDev

Reputation: 23

Getting default values of any type in Python3

Assuming I want to make a function in python that just returns the default value of a given type as a parameter:

def PrintDefaultValue(valueType: type):
   print(default(type)) // ?? # <-- how I get that with a type instance

For example if I got type of list that It should return an empty list. If I got a string as a type it should return "". If I got an integer as a type it should return 0.

Upvotes: 0

Views: 351

Answers (0)

Related Questions