0

For example I have a goodbye ascii art message that I want to display when i type "exit". But if I refernce it ABOVE it's place where i define it, then it'll give me an error. If I put it above the reference point, then it works, but it doesn't look the best. Is there a way to be able to summon a function before it's seen by the program? Thank you:)

3
  • 1
    I recommend simply getting used to the look of function calls being below their definitions. Commented Apr 9, 2016 at 10:16
  • Not even in Javascript (pretty much the world's most modern commonly used scripting language) has this feature. In DOM JS, you have document.onready, but that's pretty much the extent. Commented Apr 9, 2016 at 10:46
  • This is, because programming languages have always been written this way Commented Apr 9, 2016 at 10:46

2 Answers 2

1

Not really, but you can get close:

def main ():
    # ... Do things
    f ()
    # ... Do other things

def f ():
    print ('hello')

main ()
Sign up to request clarification or add additional context in comments.

Comments

0

No, but if you want you can put that function in another file and import it so that the main file looks pretty

main.py

from other import exit

# do something

exit()

other.py

def exit():
    print("ASCII goodbye")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.