Forum Discussion
I haven't used the TC IDE with Python, but the indentation use is deliberate.
Python is designed to work this way.
https://www.python.org/dev/peps/pep-0008/
It is meant to encourage neat code design. And stop spaghetti code. Which I guess it does as spaghetti code in Python quickly becomes unreadable.
I guess if you REALLY wanted visual separators, you could always just use comments?
Hi Colin,
> Python is designed to work this way.
Yes, I know this.
This talk is, actually, out of scope, so quick comment without the intention for the discussion. :)
It is my personal opinion that not bad idea (code visual clarity) was implemented in an average way. The worst thing is that if for some reason (poor web page formatting, different editors, any other reason) original indentation of your code is broken, it is not easy task to restore it (which is equivalent to restore of the code logic). With the majority of other languages (Pascal, C, Java... Even VB) this is a matter of automated formatting.
In addition, personally I had a lot of inconveniences because of this Python feature. The case that I am used to use temporary debug logging. Especially in cases when debugger is not available. (E.g. TestExecute or Python without IDE set up.) To have those temporary debug logging statements to be easily identifiable later, I used to put them at the very beginning of the line. This is fast and makes those temporary lines of code visually quickly identifiable. Obviously, this approach does not work with Python and I had to indent those temporary statements and mark them with some comment to be able to identify them later. (BTW, I don't like automatic formatting in Visual Studio because of the same exact reason.)
Related Content
- 4 years ago
- 2 years ago
Recent Discussions
- 2 days ago