Home > Mobile >  How to change the default value of a python library?
How to change the default value of a python library?

Time:12-10

I'm using openpyxl to create charts, I want to know if there is a way to change the default style value directly in the library.

So I don't have to always change it in each new graphic.

CodePudding user response:

Is it global variable? Then:

global my_var
my_var="new_value"

Is it class/instance property? Then:

Some_obj.some_field = "new_value"

Also, there may be some setters to do it. If they are presented, use them. Like:

Some_obj.set_default_style(arg1, arg2)

Also, if default style is a class, you can subclass it and customize as you want.

CodePudding user response:

def student(firstname, lastname ='Mark', standard ='Fifth'):

print(firstname, lastname, 'studies in', standard, 'Standard')
  • Related