Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is '$' in python? [duplicate]

Tags:

python

shell

As a beginner in Python, I'm reading a book written by Bill Lubanovic

I found something weird.

In that book, After saving simple code in test1.py, which is

print("This standalone program works!")

it says python can run it by typing in

$ python test1.py

However, whenever I try to use that, syntax error happens.

Although I know there are other methods like using exec() which I found in this website, I wanna know why book uses that method which doesn't work at least for me.

like image 635
smw1991 Avatar asked Feb 01 '16 06:02

smw1991


People also ask

What are duplicates in Python?

What are duplicates in a list? If an integer or string or any items in a list are repeated more than one time, they are duplicates.

Does tuple allow duplicates in Python?

Tuple is a collection which is ordered and unchangeable. Allows duplicate members.


1 Answers

It means you need to type everything but the $ in the terminal.

python test1.py

It's just a convention though. Authors also use > python test1.py and other notations.

I don't know which version of his book you're reading, but he mentions it in this version.

In the example that follows, $ is a sample system prompt for you to type a command like python in the terminal window. We’ll use it for the code examples in this book, although your prompt might be different.

like image 119
Hugo O. Rivera Avatar answered Sep 21 '22 15:09

Hugo O. Rivera