Is there a more pythonic way to have multiple defaults arguments to a class?
<p>I have a class with many defaults since I can't function overload. Is there a better way than having multiple default arguments, or using kwargs? </p>

<p>I thought about passing a dictionary in to my class but then how do I control whether or not the necessary arguments will be passed in? </p>

<p>If there's a more pythonic way that I should be doing this?</p>

<pre class="lang-py prettyprint-override"><code>class Editor:
    def __init__(self,
                 ffmpeg: str,
                 font_file=None,
                 font_size=148,
                 font_color="white",
                 title_length=5,
                 title_x="(w-text_w)/2",
                 title_y="(h-text_h)/2",
                 box=1,
                 box_color="black",
                 box_opacity=0.5,
                 box_border_width=25):
        self.ffmpeg = ffmpeg
        self.commands = {'help': [self.ffmpeg, '-h']}
        self.command_sequence = []
        self.titles= {"font": {"file": font_file,
                               "size": font_size,
                               "color": font_color},
                      "length": title_length,
                      "box": {"status": box,
                              "color": box_color,
                              "opacity": box_opacity,
                              "borderw": box_border_width},
                      "coordinates": {"x": title_x,
                                      "y": title_y}}
</code></pre>

<p>You can specify default attributes on the class object itself if you expect them to be pretty standard, which can then be obscured by re-assigning those attributes on the instance when desired. You can also create multiple constructors using <code>@classmethod</code>, if you want different groups of arguments to be passed in.</p>

<pre><code>class Editor(object):
    font_file: None
    font_size: 148
    def __init__(self, ffmpeg=str):
        self.ffmpeg = ffmpeg
    @classmethod
    def with_box(cls, ffmpeg=str, box=1):
        new_editor = cls(ffmpeg)
        new_editor.box = box
        return new_editor
</code></pre>

<p>And then you would call:</p>

<pre><code>Editor.with_box(ffmpeg=int, box=2)
</code></pre>

<p>and get back a properly box-initialized Editor instance.</p>

python class constructor default-arguments