Domanda

I've been learning Python, and I keep running into the $ character in online documentation. Usually it goes something like this:

$ python ez_setup.py (Yeah, I've been trying to install setup tools)

I'm fairly certain that this command isn't for the python IDE or console, but I've tried windows cmd and it doesn't work. Any help?

È stato utile?

Soluzione

As of now, Python does not implement $ in its syntax. So, it has nothing to do with Python.

Instead, what you are seeing is the terminal prompt of a Unix-based system (Mac, Linux, etc.)

Altri suggerimenti

When you open up command prompt in Windows, you'll see something like:

C:\Users\Michael0x2a\Blah> 

The $ symbol is the equivalent in Linux-based systems.

Whenever you see the $ sign, simply ignore it and type in the rest of the line without modification.

The $ is the command prompt. It is used to signify that python ez_setup.py should be run on a command line and not on a python/perl/ruby shell

You might also see % python ez_setup.py, which also means the same thing

As the two previous answers told, $ is the beginning of commandline prompt waiting for your input in Unix/Linux -systems. In Windows the similar example notation would be like

C:\> python ez_setup.py

So you don't have to write the dollar sign. Just imagine the beginnings of Windows CMD or Powershell prompt in the beginning of line :)

You can read more discussion about the history of dollar sign from Superuser.

The Odin Force Project clarified the use of $ quite nicely in their Foundations lesson:

[T]ake a look at the following text: $ whoami This is a terminal command because it begins with a $. The $ is saying “Hey! Enter what follows in your terminal.” This means that we must exclude the $ when entering any command. In the example above, we would only enter whoami in our terminal. This is a common indicator so make sure that you aren’t entering $ before a command.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top