How to call a function in a function in python
<p>I have a problem about function in python, and i'm pretty new in programming, so please giving your examples in the simplest way, thanks</p>

<p>I want to call a function in a function like this:</p>

<pre><code>def func1 (a):
    b = a + 1
    def func2():
       c = b*3
       print c
    def func3():
       c = b/5
       print c

func1(5).func2()
</code></pre>

<p>how can i call func2 inside func1 or func3 inside func1 ? and yes, i do need func1, func2 and func3, i don't want to use class</p>

<p>There is a way to achieve the syntax you want but it is <strong>highly irregular</strong> and I would <strong>strongly</strong> advise against using it. It is hacky.</p>

<pre><code>def func1(a):
    b = a + 1
    def func2():
       c = b*3
       print c
    def func3():
       c = b/5
       print c
    func1.func2 = func2
    func1.func3 = func3
    return func1
</code></pre>

<p>Now, inside the interpreter shell:</p>

<pre><code>&gt;&gt;&gt; def func1(a):
...     b = a + 1
...     def func2():
...        c = b*3
...        print c
...     def func3():
...        c = b/5
...        print c
...     func1.func2 = func2
...     func1.func3 = func3
...     return func1
... 
&gt;&gt;&gt; func1(5).func2()
18
&gt;&gt;&gt; 
</code></pre>

<p>Please, for Guido, do not do this.</p>

python function nested