Tas_mania wrote:
Quote:
I am really hoping to get into Python scripting Gimp 3.0 plug-ins next year. This is going to help me immensely.
Thanks Ofnuts!
I'm reading
Learn Python The Right Way I agree with what the author says about C and Java both really hard to master. I noticed some of the Gimp 3 python plugins are compiled into an exe like C files.
C, possibly, full of traps and small details you have to care for.
Java, no. Java can be a bit verbose, but when your Java code compiles, it sort of makes sense. In Java, you can't add Apples and Oranges, unless the receiving variable is a count of Fruit. In Python, your first runs are mostly trying to catch typos in variable names and other completely stupid mistakes. You can improve things in Python by using an IDE and using the "type hints" that have been introduced in Python 3.8 so you can write something like:
def getConfigArgs(config: Gimp.ProcedureConfig, *argNames: str):
then if you try to call that constructor with something other than a ProcedureConfig and a bunch of strings the IDE will show you the error right away, and when doing code completion you can even hope that it will suggest variables that already have the right type.
Of course it starts to look like Java, where you have to know what you are doing and where you are going.
But then I'm writing a lot of Python3 code these days, and this helps immensely. I even enjoy times where the code runs on the first try!
Quote:
I noticed some of the Gimp 3 python plugins are compiled into an exe like C files.
Uh? The only reason to do this would be to hide the code, because this kind of "compilation" is more like packaging the code and a Python runtime in a bi blob. What you can see in Gimp is a __pycache__ directory, where code compiled on the fly in a previous run is kept in the cache to avoid being recompiled on subsequent runs. Since in Gimp3 plug-ins are all in their own directory, it is easy to distribute the plug-in with separate module files and these end-up precompiled in __pycache__.