NameError: name 'form' is not defined (Python3)
<p>Basically the <code>main</code> method takes user input, checks it and calls the <code>first</code> method if the user doesn't enter <code>quit</code>.</p>

<p>The <code>first</code> method checks the first section of the input and calls one of the other methods depending on what the user enters. This is the point I get an error; when the <code>first</code> method calls the <code>form</code> method, for example, I get an <code>NameError: name 'form' is not defined</code> exception. I'm a little confused about this since I've defined each method and they're all spelt correctly, also when I call the <code>quit</code> method it works perfectly fine.</p>

<p>Main method: </p>

<pre><code>if __name__ == '__main__':
        for line in sys.stdin:
                s = line.strip()
                if not s: break
                if (str(s) == "quit"): quit()
                elif (str(s) == "quit") == False:
                        a = s.split()
                        print(a)
                        if (len(a) is 2): first(a)
                        elif (len(a) is 3): first(a)
                        else: print("Invalid Input. Please Re-enter.")
</code></pre>

<p>First method:</p>

<pre><code>def first(a = list()):
        word = a[0]

        if word == "ls":
                ls(a[1])           
        elif word == "format":
                form(a[1])
        elif word == "reconnect":
                reconnect(a[1])
        elif word == "mkfile":
                mkfile(a[1])
        elif word == "mkdir":
                mkdir(a[1])
        elif word == "append":
                append(a[1], a[2])                               
        elif word == "delfile":
                delfile(a[1])
        elif word == "deldir":
                deldir(a[1])
        else:
                print("Invalid Prompt. Please Re-enter.")
</code></pre>

<p>Other methods (these are all called from the first method):</p>

<pre><code>def reconnect(one = ""):
        print("Reconnect")

def ls(one = ""):
        print("list")

def mkfile(one = ""):
        print("make file")

def mkdir(one = ""):
        print("make drive")

def append(one = "", two = ""):
        print("append")

def form(one = ""):
        print("format " + one)

def delfile(one = ""):
        print("delete file")

def deldir(one = ""):
        print("delete directory")

def quit():
        print("quit")
        sys.exit(0)
</code></pre>

<p>this error is because of </p>

<pre><code>    elif word == "format":
            form(a[1])
</code></pre>

<p>python basically doesn't know what form is.</p>

<p>let me show you:</p>

<pre><code>gaf@$[09:21:56]~&gt; python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; form()
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
NameError: name 'form' is not defined
&gt;&gt;&gt;
</code></pre>

<p>there is two ways out</p>

<pre><code>&gt;&gt;&gt; def form():
...     pass
...
&gt;&gt;&gt; form()
&gt;&gt;&gt; form
&lt;function form at 0x7f49d7f38a28&gt;
&gt;&gt;&gt;
</code></pre>

<p>or import it form some library using</p>

<pre><code>import 
</code></pre>

<p>command</p>

<p>also order is matters too</p>

<pre><code>try:
    form()
except NameError:
    print('Oops name error raise above')


def form():
    print('form foo is called')

try:
    form()
except NameError:
    print('Oops name error raise below')
</code></pre>

<p>will give you</p>

<pre><code>/home/gaf/dashboard/bin/python /home/gaf/PycharmProjects/dashboard/test.py
Oops name error raise above
form foo is called

Process finished with exit code 0
</code></pre>

<p>P.S.
take a look at pep8
your code is a mess %)
but no worries this what everybody does with first language</p>

python error-handling