>>I have a code here. I understand i can not draw lines without the >>global definition of lastX and lastY. But still confused by its use. >>when should we use global definition?
If you don't use classes then you will need to use global variables any time you want to pass information between functions and the functions have a predetermined interface that precludes making the data parameters. Thus in your case the callback click(event) can only take the one parameter, event so you must use global variables. Similarly you need to use globals where you need to maintain state between function calls (even of the same function) Otherwisde you should be able to avoid globals. Using OOP allows you to hide the global functions inside an object which solves both of the above problems. HTH, Alan G. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor