0

I just started the 'official' Python tutorial at https://docs.python.org/3/tutorial/interpreter.html and I have a question.

When describing how to execute python commands from the command line, it says the following:

A second way of starting the interpreter is python -c command [arg] ..., which executes the statement(s) in command, analogous to the shell’s -c option. Since Python statements often contain spaces or other characters that are special to the shell, it is usually advised to quote command in its entirety with single quotes.

Below are two commands that I ran from cmd on Windows 10 Pro using Python 3.8.3. Can anyone help explain why enclosing the command in single quotes doesn't seem to work?

C:\Users\______>py -c "print('Hello World!')" 

Hello World!

C:\Users\______>py -c 'print("Hello World!")'
(no output returned)

I know the tutorial is written for Linux users, just trying to understand why it doesn't appear to work for Windows.

tripleee
  • 175,061
  • 34
  • 275
  • 318
Hyper10n
  • 31
  • 3
  • Because quoting in the Windows CMD interpreter is completely different. If you can't get rid of Windows entirely, maybe install Git Bash if you don't simply want to switch to a Windows-oriented introduction. – tripleee Aug 08 '20 at 16:37
  • https://superuser.com/questions/324278/how-to-make-windows-command-prompt-treat-single-quote-as-though-it-is-a-double-q This might address some of your concerns. – Puneet Singh Aug 08 '20 at 17:04
  • Thank you both for the links. I'm still new to searching SO/internet and programming. After reading through everything, I installed the Ubuntu developer tools for Windows so I can have the expected experience in the tutorial. – Hyper10n Aug 08 '20 at 22:07

0 Answers0