FreeCADGui.doCommand() has a parsing error ?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
techGuy
Posts: 126
Joined: Sat Jun 18, 2022 12:48 am

FreeCADGui.doCommand() has a parsing error ?

Post by techGuy »

This statement fails:

Code: Select all

FreeCADGui.doCommand("command = 'EOT' + '\n' ")
The error is:

Code: Select all

18:14:17      FreeCADGui.doCommand("command = 'EOT' + '\n' ")
18:14:17    File "<string>", line 1
18:14:17      command = 'EOT' + '
18:14:17                        ^
18:14:17  SyntaxError: unterminated string literal (detected at line 1)
This should be a valid Python command:

Code: Select all

 command = 'EOT' + '\n'` 
It also fails with

Code: Select all

 command = 'EOT +\n'
Am I missing something ? Do I need to double escape the

Code: Select all

\n
, or something, ie

Code: Select all

\\n
?

Thanks
Last edited by techGuy on Wed Feb 08, 2023 1:32 am, edited 1 time in total.
User avatar
chennes
Veteran
Posts: 3882
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: FreeCADGui.doCommand() has a parsing error ?

Post by chennes »

You probably need to escape the backslash -- try with "\\n" instead.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
techGuy
Posts: 126
Joined: Sat Jun 18, 2022 12:48 am

Re: FreeCADGui.doCommand() has a parsing error ?

Post by techGuy »

Ignore !
techGuy
Posts: 126
Joined: Sat Jun 18, 2022 12:48 am

Re: FreeCADGui.doCommand() has a parsing error ?

Post by techGuy »

chennes wrote: Wed Feb 08, 2023 1:32 am You probably need to escape the backslash -- try with "\\n" instead.
Yes, that worked.
Post Reply