How do you set a default value for a variable in Python3?
<p>For an assignment I have to write a program that can create directories and files, we have to write a DirectoryEntry class to help do this, and for part of it we have to create a name for the file or directory. If a name is entered then we just use the name but if no name is entered we just use 9 spaces. </p>

<p>I don't know how to do this using the <code>__init__</code> method because Python3 doesn't allow you to have more then one constructor method.</p>

<p>Right now it just looks like:</p>

<pre><code>def __init__(self, name):
    self.type = "f:"
    self.name = name
    self.length = "0000"
    self.colon = ":"
    self.blocks = ["000", "000", "000", "000", "000", "000", "000", "000", "000", "000", "000", "000"]`    
</code></pre>

<p>You can use:</p>

<pre><code>def __init__(self, name='your_default_name'):
</code></pre>

<p>Then you can either create an object of that class with <code>my_object()</code> and it will use the default value, or use <code>my_object('its_name')</code> and it will use the input value.</p>

python default-value default-constructor