DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Python variable __name__ shows strange behavior in Diadem 2026

Hi!

I've been using Python with Diadem 2020.

Now I am testing Python with Diadem 2026 and observed a strange behavior:

 

I am writing my Python scripts like this, so that the code is only executed when the explicit script was started:

 

def main():

   pass

 

if __name__ == "DIAdem":

   main()

 

 

This worked fine in Diadem 2020.

But now with Diadem 2026, the output of "__name__" is different when started from the shortcuts (F1 to F12).

If you open the script editor in Diadem 2026, open a script and run this script, the output of "__name__" will still be "DIAdem".

But if you run the same script from one of the shortcuts, the output will be the filename.

Additionally, if you open the script in the script editor and run the script from the shortcut afterwards, the output will be "DIAdem" again.

 

How comes that?

How do I fix this behavior, so that I don't have to update all of my scripts?

 

Versions: Diadem 2026 Q2

Python 3.13 and 3.7 (Diadem 2020 installation)

Tested both versions of Python. Didn't have any impact. 

 

Thanks in advance.

 

André

0 Kudos
Message 1 of 1
(455 Views)