Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behaviour in TagUI write and TagUI for Python write() - by design #44

Closed
ck81 opened this issue Aug 12, 2019 · 4 comments
Closed
Labels

Comments

@ck81
Copy link

ck81 commented Aug 12, 2019

Hi Ken,

Just tried some write() in TagUI-Python

Found out that

  • write in TagUI automatically includes new line at the end of the write string
  • write() in TagUI-Python does not

Can I confirm the above behaviour?

Would be great if the two can be standardized - so that it's easier for people who need to port scripts from TagUI to TagUI-Python.

@kensoh kensoh changed the title write Different behaviour in TagUI write step and TagUI for Python write() Aug 12, 2019
@kensoh kensoh changed the title Different behaviour in TagUI write step and TagUI for Python write() Different behaviour in TagUI write step and TagUI for Python write() - by design Aug 12, 2019
@kensoh kensoh added the query label Aug 12, 2019
@kensoh kensoh changed the title Different behaviour in TagUI write step and TagUI for Python write() - by design Different behaviour in TagUI write and TagUI for Python write() - by design Aug 12, 2019
@kensoh
Copy link
Member

kensoh commented Aug 12, 2019

Hi CK, yes you are right! The behaviour is intentional and by design.

It can't be standardised because the target users for both projects are different. TagUI is meant more for business users and non-developers, so things are done as much as possible to simplify tasks for them. This includes automatically inserting line break '\r\n' for write step.

However, TagUI for Python is meant more for Python users. Thus write() step cannot automatically add the line break characters '\r\n' as that means users cannot write a series of strings to a file sequentially without inserting line breaks in between. That would be very un-Pythonic and non-standard programming language behaviour.

In the interim, for TagUI users who want to port to TagUI for Python, they will face this difference. Workaround will be inside the write() function in tagui.py (search for def write(), change the following line

write_output_file.write(_py23_write(text_to_write)

to something like

write_output_file.write(_py23_write(text_to_write + '\r\n')

This seems hacky, but if standardise the two, the group of Python users using this package directly, compared to existing TagUI users who port to Python, will be a much larger group. And they can't be paying the price to address the the smaller group's needs, especially if it is deviating from standard programming languages best practices. If change TagUI write to be without '\r\n' it will also break backward compatibility of its existing user scripts, thus also not a suitable solution.

@ck81
Copy link
Author

ck81 commented Aug 13, 2019

Hi Ken,

Thanks for the detailed explanation. Know where you're coming from.

This is not a big issue in python, because it's now very easy to use def to add a little function in python to automatically add a "\n" at the end of each write.

You may want to highlight this in your documentation for TagUI-Python though. I'm sure there will some users like me trying to port TagUI script into TagUI-Python and bump into this wondering what's happening.

@kensoh
Copy link
Member

kensoh commented Aug 13, 2019

That's a good suggestion CK. From your experience so far, other than write() and visible(), have you experienced other differences in behaviour between TagUI for Python functions and TagUI steps that would help to be documented?

@kensoh
Copy link
Member

kensoh commented Aug 20, 2019

Closing this as CK created a new issue #47 with details of the comparison!

@kensoh kensoh closed this as completed Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants