Skip to main content
Solved

Why we choose Only Python not other for scripting in FME?


Forum|alt.badge.img
Why we choose Only Python not other for scripting in FME?

Best answer by takashi

Hi,

 

 

I frequently use Python on the same reason as David, but also use Tcl when string operations are required primarily. In Japanese locale, I need to think of encoding issues carefully when writing Python scripts to perform string operations. It's really troublesome, although it's not impossible. Tcl is better on this point, I don't need to consider about such encoding issues. Sometimes, therefore, both PythonCaller (manipulating geometries and/or performing math calculations) and TclCaller (performing string operations) exist in the same workspace.

 

 

Takashi

 

View original
Did this help you find an answer to your question?

12 replies

fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • October 31, 2015
Not completely sure of the question, but it is true that Python is very popular as a scripting/programming language for GIS people in particular and the larger developer community in general. So it is definitely a front runner.

 

 

That said, you can use Tcl in FME in pretty much the same ways as you can use Python. Tcl was popular when we first began developing FME and plays an important role in FME, but it has a number of shortcomings that Python addresses, not the least of which is that it is far less popular and so there is less knowledge about it in general.

 

 

We have a JavascriptCaller as well, but at this point it is far less capable than our Python and Tcl integrations.

david_r
Evangelist
  • November 2, 2015
Hi

 

 

Personally, I prefer Python to both Tcl and Javascript because of, among other things, legibility, ease of development, tight integration with the FME engine and the abundance of built-in modules that are already included in the Python distribution.

 

 

David

 

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • November 2, 2015
Hi,

 

 

I frequently use Python on the same reason as David, but also use Tcl when string operations are required primarily. In Japanese locale, I need to think of encoding issues carefully when writing Python scripts to perform string operations. It's really troublesome, although it's not impossible. Tcl is better on this point, I don't need to consider about such encoding issues. Sometimes, therefore, both PythonCaller (manipulating geometries and/or performing math calculations) and TclCaller (performing string operations) exist in the same workspace.

 

 

Takashi

 


david_r
Evangelist
  • November 2, 2015
takashi wrote:
Hi,

 

 

I frequently use Python on the same reason as David, but also use Tcl when string operations are required primarily. In Japanese locale, I need to think of encoding issues carefully when writing Python scripts to perform string operations. It's really troublesome, although it's not impossible. Tcl is better on this point, I don't need to consider about such encoding issues. Sometimes, therefore, both PythonCaller (manipulating geometries and/or performing math calculations) and TclCaller (performing string operations) exist in the same workspace.

 

 

Takashi

 

That's an interesting point. We also get into these issues here in Europe with some accents, and it's true that it can be a pain. However, I've found that if I cast all strings to unicode before processing it is rather straight forward. Concerning the FMELogFile() class, I've created a small wrapper around it that converts back to the local character set when necessary.


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 2, 2015
takashi wrote:
Hi,

 

 

I frequently use Python on the same reason as David, but also use Tcl when string operations are required primarily. In Japanese locale, I need to think of encoding issues carefully when writing Python scripts to perform string operations. It's really troublesome, although it's not impossible. Tcl is better on this point, I don't need to consider about such encoding issues. Sometimes, therefore, both PythonCaller (manipulating geometries and/or performing math calculations) and TclCaller (performing string operations) exist in the same workspace.

 

 

Takashi

 

In fact, there is another Japanese specific issue other than the 'unicode'. The default encoding of Windows Japanese edition is called "cp932". In the code set, a Japanese character is represented by 2 bytes. The worse, there are some characters containing 0x5C (backslash) as the second byte. As you know, the backslash escapes the next character, so it causes some troubles if you write a string literal or regular expression containing such a character. It seems to be involved in Python interpreter, Tcl doesn't have this issue. It's also a reason that I use Tcl for string operations.


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 2, 2015
takashi wrote:
Hi,

 

 

I frequently use Python on the same reason as David, but also use Tcl when string operations are required primarily. In Japanese locale, I need to think of encoding issues carefully when writing Python scripts to perform string operations. It's really troublesome, although it's not impossible. Tcl is better on this point, I don't need to consider about such encoding issues. Sometimes, therefore, both PythonCaller (manipulating geometries and/or performing math calculations) and TclCaller (performing string operations) exist in the same workspace.

 

 

Takashi

 

In passing, I know that the issue I mentioned above can be avoided by putting a coding declaration on the top of the Python script. However, the script may not be run on other platform (e.g. Linux) any longer. I don't want that.


david_r
Evangelist
  • November 2, 2015
takashi wrote:

In fact, there is another Japanese specific issue other than the 'unicode'. The default encoding of Windows Japanese edition is called "cp932". In the code set, a Japanese character is represented by 2 bytes. The worse, there are some characters containing 0x5C (backslash) as the second byte. As you know, the backslash escapes the next character, so it causes some troubles if you write a string literal or regular expression containing such a character. It seems to be involved in Python interpreter, Tcl doesn't have this issue. It's also a reason that I use Tcl for string operations.

Interesting, I didn't know it was that bad... I guess that might also be why the Yen-character shows up rather than the backslash on japanese terminals?


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 2, 2015
david_r wrote:

Interesting, I didn't know it was that bad... I guess that might also be why the Yen-character shows up rather than the backslash on japanese terminals?

Since the yen-character is a single byte, it doesn't concern to the issue directly. However it becomes a wall separating us from foreign friends sometimes. I always have to add a comment to a screenshot showing yen... Anyway, multi-byte characters ending with 0x5C are so troublesome!


fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • November 4, 2015
takashi wrote:
Hi,

 

 

I frequently use Python on the same reason as David, but also use Tcl when string operations are required primarily. In Japanese locale, I need to think of encoding issues carefully when writing Python scripts to perform string operations. It's really troublesome, although it's not impossible. Tcl is better on this point, I don't need to consider about such encoding issues. Sometimes, therefore, both PythonCaller (manipulating geometries and/or performing math calculations) and TclCaller (performing string operations) exist in the same workspace.

 

 

Takashi

 

All the more reason for us to get the unicode Python API completed and integrated. Sorry for the issues in the meantime. A rare area where Tcl, which says it is all in UTF8, has an advantage of Python...


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 4, 2015
fmelizard wrote:

All the more reason for us to get the unicode Python API completed and integrated. Sorry for the issues in the meantime. A rare area where Tcl, which says it is all in UTF8, has an advantage of Python...

I guess that the issue caused by a string literal or regular expression containing "damemoji" (characters having 0x5C as 2nd byte) might be resolved, if the Python script editor of Workbench would encode the user entered script to UTF-8. However, I'm afraid that UTF-8 editor may cause bad side-effects...


danilo_fme
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • December 11, 2015

Hi all, very interessnt this question. With Python and FME we have a goods results with our clients.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 30, 2016

I prefer tcl, much more elegant.

Huge libraries. (but so have others)

Big forums. (but so have others)

But do switch to python (now and then). For no apperant reason..just because we can.

Lately messing more with autocad and doing LISP (because fme ACAD writer and Styler are lacking in lots of respects)..talk about legibility..lol.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings