forward-declaration

How do I forward-declare a function to avoid `NameError`s for functions defined later?

How do I forward-declare a function to avoid `NameError`s for functions defined later? Question: Is it possible to forward-declare a function in Python? I want to sort a list using my own cmp function before it is declared. print "n".join([str(bla) for bla in sorted(mylist, cmp = cmp_configs)]) I’ve put the definition of cmp_configs method after …

Total answers: 17