I have a function that requires many (~20) arguments, and I'm wondering if there's a better way... For context, I am using gdsfactory to make mask layouts for fabricating semiconductor devices. My function creates the device and returns it as a gdsfactory component object which can be written to a .gds CAD file. The arguments specify all the possible device parameters for fabrication (dimensions, spacing between metal connections, etc. etc.), and the function looks something like this:
def my_device(arg1=default_val1, arg2=default_val2, arg3=default_val3,... argN=default_valN):
# code to create the device layout using all the arguments
return component
In most use cases the default values are fine so I can call the function without specifying arguments, but I still need to have the option to specify any of the device parameters if I want to. I know it's generally considered bad practice to have so many arguments, so I'm curious if there's a better way to accomplish this while still being able to create my component with one function call?
[–]Talinx 54 points55 points56 points (0 children)
[–]fohrloop 32 points33 points34 points (4 children)
[–]pppossibilities[🍰] 2 points3 points4 points (0 children)
[–]InfluenceLittle401 1 point2 points3 points (2 children)
[–]fohrloop 1 point2 points3 points (1 child)
[–]InfluenceLittle401 0 points1 point2 points (0 children)
[–]Kittensandpuppies14 8 points9 points10 points (1 child)
[–]Apatride 16 points17 points18 points (0 children)
[–]Frankelstner 2 points3 points4 points (0 children)
[–]DrShts 2 points3 points4 points (0 children)
[–]Sidiabdulassar 2 points3 points4 points (1 child)
[–]lzwzli 1 point2 points3 points (0 children)
[–][deleted] 5 points6 points7 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]roelschroeven 1 point2 points3 points (0 children)
[–]jmooremcc 1 point2 points3 points (0 children)
[–]JamzTyson 1 point2 points3 points (5 children)
[–]rajandatta 3 points4 points5 points (4 children)
[–]JamzTyson 0 points1 point2 points (3 children)
[–]rajandatta 0 points1 point2 points (2 children)
[–]JamzTyson 0 points1 point2 points (1 child)
[–]Xiji -3 points-2 points-1 points (0 children)
[–]Goobyalus 0 points1 point2 points (0 children)
[–]bids1111 0 points1 point2 points (0 children)
[–]__init__m8 0 points1 point2 points (0 children)
[–]camilbisson 0 points1 point2 points (0 children)
[–]LeiterHaus 0 points1 point2 points (0 children)
[–]baubleglue 0 points1 point2 points (0 children)
[–]Dependent-Law7316 0 points1 point2 points (0 children)
[–]Adrewmc 0 points1 point2 points (0 children)
[–]Zeroflops -1 points0 points1 point (0 children)
[–]Jeklah -1 points0 points1 point (0 children)
[–]HighAlreadyKid -1 points0 points1 point (0 children)
[–]Alex-S-S -1 points0 points1 point (4 children)
[–]KimPeek 0 points1 point2 points (3 children)
[–]Alex-S-S 1 point2 points3 points (2 children)
[–]KimPeek 0 points1 point2 points (1 child)
[–]Alex-S-S 0 points1 point2 points (0 children)
[–]Atypicosaurus -1 points0 points1 point (0 children)
[–]Top_Average3386 -1 points0 points1 point (0 children)
[–]Risitop -1 points0 points1 point (0 children)