missnomer
missnomer

Reputation: 145

What happens when I run python -v on the terminal instead of python -V?

A huge list sprung up on my terminal after I misstyped python -v into my terminal. listing a few here:

     # clear builtins._
     # clear sys.path
     # clear sys.argv
     # clear sys.ps1
     # clear sys.ps2
     # clear sys.last_type

I have no idea what is happening.

Upvotes: 1

Views: 1488

Answers (2)

Ben
Ben

Reputation: 6348

From man python:

      -v      Print a message each time a module is initialized,  showing  the
              place  (filename  or  built-in  module) from which it is loaded.
              When given twice, print a message for each file that is  checked
              for  when  searching for a module.  Also provides information on
              module cleanup at exit.

As a side note, the next time you want to know what a particular command switch does, use the following commands:

man <command>

This places you in the man pages. You can move up and down with j and k, exit with q. To search, type /search_term and jump between matches with n and N.

So, in this case:

man python

Now we're in the man pages for Python. Search for the switch in question:

/-v

Use n to jump to the next match and N if you overshoot it until you find the relevant passage.

Upvotes: 1

Nikhil Gupta
Nikhil Gupta

Reputation: 291

when you type python on terminal or command prompt then it will open python interpreter in interactive mode.

$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

When you type python -v , then it will open do the same thing but in verbose mode so you will see lots of messages which tell that which module is being initialized and from where. You will also see messages regardign module clean up when you type exit()

You can type -vv to make it more verbose

If you want to see the version of python then use python --version or python -V (Please note capital V)

More details can be found here:

https://docs.python.org/2/using/cmdline.html#cmdoption-v

-v Print a message each time a module is initialized, showing the place (filename or built-in module) from which it is loaded. When given twice (-vv), print a message for each file that is checked for when searching for a module. Also provides information on module cleanup at exit. See also PYTHONVERBOSE.

Upvotes: 3

Related Questions