I have a question; I have some code for a thread:
if __name__ == "__main__":
x = makeThread("Thread 1", thread_function, ThreadKeyArg = "PersonalKey\n")
xx = makeThread("Thread 2", thread_function, ThreadIDArg = 11111)
xxx = makeThread("Thread 3", thread_function, ThreadKeyArg = "AnotherPersonalKey\n")
xxxx = makeThread("Thread 4", thread_function, ThreadIDArg = 1234)
then, I ask if x is in locals()
or globals()
. If the statement is true, then print("something")
occurs. Here is that section of code:
if x in locals() or globals():
print("something")
This code does make the if
statement true, so it does print the text. However, when I put if x in locals()
or if x in globals()
, neither times do they print("something")
. Now, this does not cause me any problems, I am just wondering why this is so.