So, I have the following code sample:
from Tkinter import *
import socket
def click(*args):
sock = socket.socket()
try:
sock.connect(('localhost', 9999))
sock.send(args)
except socket.error:
print 'server is not runing'
pass
root = Tk()
root.bind("<Button-1>", click)
mainloop()
This looks pretty clear: you run the code, Tkinter window arrives, you click it, and it prints 'server is not runing', cos no server is running at 9999 port.
But if you change call of binded function from click
to click("wtf")
or even to click()
, script will print message right after window appeared, before you actually click it.
Why such thing happens?