How can I call functions that are after the same function?

Asked

Viewed 122 times

3

I have sometimes managed to call functions that are further ahead in the program. However, it takes me hours to find a way to do so. What is the easiest way? Ex:

def paintball():
    print "Olá"
    adeus()

def adeus():
    print "Adeus"

It’s just a simple way to show the problem.

1 answer

4


This:

def paintball():
    print "Olá"
    adeus()

def adeus():
    print "Adeus"

paintball()

It works, after all, adeus() is before paintball(), and the analysis of function names is only done at runtime.

Now,

def paintball():
    print "Olá"
    adeus()

paintball()

def adeus():
    print "Adeus"

This is impossible to work because at the time of execution, the name adeus() has not been evaluated in a single moment.

  • 1

    Thanks ;) Because of not doing so I spend a lot of time trying.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.