Home > Mobile >  when do we use double hash (--) in conda
when do we use double hash (--) in conda

Time:04-09

I am new to Anaconda and programming in general. In pursuit to build a thorough understanding of Anaconda, I want to understand when we use double hash/hyphens(--). For example, conda documentation says that to clone an env we have to use conda create --clone py35 --name py35- but I don't need to use -- before Remove in conda env remove --name bio-env. How can I know what command requires two dashes?

CodePudding user response:

So first off, no one calls hyphens "hashes"; they're hyphens or dashes.

Secondly, there's no 100% pattern, but the general rule is:

  1. Subcommands (things that change what you're doing completely, like the create and env command, and env's further subcommand, remove) are almost always positional, and not prefixed with --
  2. Required arguments are typically (though not always, especially when the number of arguments gets large enough that remembering the order would be a pain) positional, and don't use --
  3. Optional arguments (sometimes called "switches", especially if they take no argument themselves and just change the program behavior based on whether or not they are passed) are typically prefixed with --, and their order shouldn't matter. They often have a single letter form, prefixed with a single hyphen, e.g. -v might be another way to say --verbose (to turn on additional debugging output). In your case, you're passing arguments saying what you want to clone and what to name it, which presumably aren't strictly necessary (they may not need to clone another environment, and it may use a default name), thus they're switches.

It's not an exact science; you just have to learn by reading man pages or running the programs in question with the --help (sometimes just -h or more rarely, -?) switch to get usage information.

  • Related