<type>documentation</type>
<domain>intro</domain>
<id>tutorial-check-python</id>
<title>Tutorial: Check your Python Integration</title>
<date>$Date$</date>
<product>all</product>

Before starting with some code, let's make sure that Wing has succeeded in finding your
Python installation. Bring up the `Python Shell
<script:show_panel#panel_type="python-shell">`__ tool now from the ``Tools`` menu. If all
goes well, it should start up Python and show you the Python command prompt like this:

.. image:: python-shell.png
  :width: 732
  :height: 163

~~~if not WING101:
If this is not working, or the wrong version of Python is being used, you can point Wing
in the right direction with `Python Executable
<script:view_project_properties#highlighted_attrib="proj.pyexec">`__ in ``Project
Properties``, accessed from the ``Project`` menu.
~~~
~~~if WING101:
If this is not working, or the wrong version of Python is being used, you can point Wing
in the right direction with ``Python Executable`` in the `Python Configuration
<script:view_project_properties#highlighted_attrib="proj.pyexec">`__, accessed from the
``Edit`` menu.
~~~
~~~if WEBSITE:
Wing 101 does not have projects and Python environment is configured instead with
``Configure Python`` in the ``Edit`` menu.
~~~

An easy way to determine the value to use for ``Python Executable`` is to start the Python
you wish to use with Wing and type the following at Python's ``>>>`` prompt:

.. python::

  import sys
  print(sys.executable)
  
You can also use a virtualenv or Anaconda environment by selecting the ``Activated Env``
option here, but for now let's just use the base Python installation.

You will need to ``Restart Shell`` from the ``Options`` menu in the ``Python Shell`` tool
after altering ``Python Executable``.

Once the shell works, copy/paste or drag and drop these lines of Python code into it:

.. python::

  for i in range(0, 10):
      print('*' * i)
    
This should print a triangle as follows:

.. image:: python-shell-test.png
  :width: 268
  :height: 246

Notice that the shell removes common leading white space when blocks of code are copied
into it. This is useful when trying out code from source files.

Now type something into the shell, such as:

.. python::

  import sys
  sys.getrefcount(i)
  
~~~if not WING101:
Note that Wing offers auto-completion as you type and shows call signature and
documentation in the `Source Assistant
<script:show_panel#panel_type="source-assistant">`__ tool. Use the ``Tab`` key to enter a
selected completion. Other keys can be set up as completion keys with the `Editor >
Auto-completion > Completion Keys
<script:show_preferences_gui#prefname="edit.autocomplete-keys">`__ preference.
~~~

You can create as many instances of the ``Python Shell`` tool as you wish by
right-clicking on a tool tab and selecting ``Insert Tool``. Each one will run in its own
process space.

