My question now is: Is there a way to avoid using global
> variables but also avoid an object-oriented programming?
> In other words: Is it possible to pass e.g. a dictionary
> containing some information to the function called by the
> event? The reason for not wanting the object-oriented way
> is: We want to teach something to students who never
> programmed before. And to them it would be pretty hard if
> we start everything object-oriented!
The can use attrs on the function
def two_parts(event):
if event.button == 3:
two_parts.program_part = two_parts.program_part%2 + 1
print " Changed to part to ", program_part
if two_parts.program_part == 1 and event.button == 1:
plot([event.xdata], [event.ydata], marker = 'o', mfc = 'r')
if two_parts.program_part == 2 and event.button == 1:
plot([event.xdata], [event.ydata], marker = 's', mfc = 'g')
draw()
two_parts.program_part = 1
which would introduce them to attributes and pave the way to thinking
about OO.
JDH