Tired of LogMessage?

March 4th, 2005 by Patrick Boucher - Viewed 10066 times -




OK…

1
Application.LogMessage("Whatever")

Am I tired of writing this in my XSI Python scripts you think? In Python, variables are basically pointers to the actual object and everything in Python is an object, functions included… Hmmm…

Try using this at the top of your python scripts:

1
2
xsi = Application
pr = xsi.__getattr__("LogMessage")

Now you can do:

1
2
xsi.Whatever(attrib)
pr(whatever.Property)

instead of

1
2
Application.Whatever(attrib)
Application.LogMessage(whatever.Property)

All of this with absolute minimal overhead! My wrists will be thanking my little brain fart in twenty years!

3 Responses to “Tired of LogMessage?”

  1. [...] #8217;s win32com module and why you have to know it exists in the XSI context as well as a tip concerning Application.LogMessage(””)… Well why not make things a little simpler still. If you unzip thi [...]

  2. Aloys Baillet says:

    A little trick to add to this one:
    pr = Application.LogMessage is equivalent (but shorter) to Application.__getattr__(“LogMessage”)
    Python is great!

  3. [...] Python’s win32com module and why you have to know it exists in the XSI context as well as a tip concerning Application.LogMessage(“”)… Well why not make things a little simpler [...]