0

Is there a way to change the what the default end-of-line character the standard python interpreter (REPL) in Interactive Mode will accept to run a line of code? On a Windows os, the interpreter only accepts \r\n before it will run a line of code. I want to change that to \n in on a Windows machine?

Why: I use atom editor with platformio-atom-ide-terminal package and git-bash (EOL = '\n') as the Shell Override on a Windows machine (EOL = '\r\n') to run python, pyspark, and scala on a remote Linux machine (EOL = '\n') and also python on the local Windows machine (EOL = '\r\n').

I can easily change platformio-atom-ide-terminal package to run code in the attached terminal with ctrl+enter which simply passes the line of code (text) into the terminal appending only the '\n' to the end of the line of text. The code I can successfully run this way includes local Windows shell commands, remote Linux shell commands, and python, pyspark, and spark code on the remote Linux sys.

The only thing I have to do to unify everything is get the local Windows python interpreter to accept '\n' rather than '\r\n' at the end of the line to run the text passed to it.

Clay
  • 2,584
  • 1
  • 28
  • 63
  • Not exactly sure what are you trying to achieve but system-aware scripts will refer to `os.linesep` to get the current platform's default EOL sequence. Thus, you can just do `os.linesep = "\n"` and components that play good with different platforms will respect the change. – zwer Apr 02 '18 at 15:43
  • Thansk @zwer, I added the reason why to the question. I tried doing what you suggested and the python interpreter still does not accept the '\n' passed to it as an end-of-line instruction to then execute the code. This does work when using the same set-up to remote into a Linux machine via ssh. – Clay Apr 02 '18 at 16:56
  • git-bash uses MinTTY, if I remember correctly, and even if you fool REPL it will still have way to many quirks. Why don't you just launch REPL through `winpty` (i.e. `winpty python`) ? – zwer Apr 02 '18 at 17:32
  • tried `winpty /C/ProgramData/Anaconda3/python` which starts python as usual, but then the `ctrl+enter` also stops working just as before. – Clay Apr 02 '18 at 17:41
  • I abandoned trying to change the python interpreter, changing the platformio-atom-ide-terminal package to append the line with `'\r'` and use powershell works in all of my cases. – Clay Apr 02 '18 at 21:36

0 Answers0