ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
Visual Python
Tutorial
User Guide
Release Notes

MyASPN >> Reference >> Visual Python

Version 1.8.3

Table of Contents



ASPN, the ActiveState Programmer Network, features comprehensive Python programming resources. Check out:

Getting Started

In this section:

Related Tutorial Topics:

Visual Studio .NET is the next generation of Microsoft's integrated development environment. With Visual Studio .NET, Microsoft opened the Visual Studio API so that third-party software developers could write extensions to the environment. ActiveState, taking advantage of the open API, developed Visual Python, Visual Perl and Visual XSLT, three plug-ins that bring the power and popularity of these open-source languages into the rich Visual Studio IDE.

Visual Python runs within Visual Studio .NET. We have included a sample Visual Studio solution containing a Python project to help you get started. In the section below, you will open the sample project, configure the Visual Python environment defaults and begin debugging.

Configuring Editor Behavior

Editing defaults (such as tab size, word wrap, etc) can be configured for each language supported by Visual Studio. To configure Python defaults, select Tools|Options, then select the Text Editor folder, and the Python sub-folder. These Python-specific defaults override the environmental defaults specified in the All Languages sub-folder. Only items specific to Visual Python are described below; for a description of other editor options, refer to the Visual Studio .NET documentation.

General options

  • Auto list members: This option determines whether Method Tips are displayed when you enter a class or module name followed by a period.
  • Parameter information: This option determines whether Call tips are displayed when you enter a method name followed by an open parenthesis.

Tabs options

  • Smart Indenting When this option is enabled, Visual Python automatically indents lines in the editor after colons and open parenthesis. When a line ends with a colon, the following line is indented based on the configuration of the Tabs section of the the Tabs dialog. When a line ends with an open parenthesis, the following line is indented to the column following the parenthesis.

Visual Python specific options

  • Check syntax while editing If this check box is enabled, Visual Python will analyze the language syntax as you type and indicate potential errors by underlining the text with a red wavy line. A summary of syntax errors is added to the Visual Studio Task List (View|Other Windows|Task List).
  • Show code folding If this check box is enabled, Visual Python will "notice" discrete blocks of code. On the left margin of the editing workspace, plus and minus symbols will indicate sections of code that can be "folded" (that is, collapsed or expanded). Click on the plus or minus symbol to collapse or expand blocks of code. When a section of code is collapsed, you can display the hidden code by hovering the mouse pointer over the symbol that appears to the right of the first line of the collapsed block. Collapsed code blocks will be automatically opened during debugging or editor-driven modifications.

Related Tutorial Topics: Smart Indenting  Syntax Checking  Code Folding 

Configuring Project Defaults

Environment defaults, such as the location of the Python interpreter, are specified using the Tools|Options|Projects|VisualPython dialog. As necessary, configure the following options:

  • Python Interpreter location: contains the location of the Python interpreter file installed by ActivePython. The default location is c:\Python21\python.exe
  • PYTHONPATH: contains the location of the Python library files that are imported into your Python programs.

Related Tutorial Topics: Solutions and Projects 

Debugging the Sample Project

Click Start|Programs|ActiveState Visual Python|Samples|Dramatis Personae. This will automatically load Visual Studio. On the banner that displays while Visual Studio loads, notice the logo for ActiveState Visual Python along with logos for other registered languages.

In the Solution Explorer, double-click the Python file to open it for editing. (If the Solution Explorer pane is not visible in the Visual Studio .NET workspace, click View|Solution Explorer.) Press F10 (Debug|Step Over) or F11 (Debug|Step Into) to begin, and continue through the document by pressing F11. Set breakpoints by clicking in the grey margin to the left of the editing pane.

You can use the sample solution to familiarize yourself with using Visual Python to edit and debug Python programs. The next section discusses how to create a new Python project and add files to your project.

Related Tutorial Topics: Running Programs  Debugging Programs 

Top

About Solutions and Projects

In this section:

Related Tutorial Topics:

The fundamental unit of organization in Visual Studio .NET is the solution. If you've worked with Visual InterDev 6.0, you're familiar with solutions. If you're a Visual Studio 6 user, a solution is similar to a "Workspace". Solutions can contain one or more projects, with each project associated with a programming language.

Solutions are collections of projects, and projects are collections of individual "items". In Visual Python, "items" are equivalent to files. When you create a new project from the File menu, Visual Studio .NET automatically creates a new solution. Alternatively, you can add a new project to an existing solution by right-clicking the solution name (in the Solution Explorer pane) and selecting Add|New Project.

In Visual Studio there is one primary program per project, so you must create a project for each Python program you intend to work with in Visual Studio. A Python program is considered to be a top-level .py file, in which execution begins, and any additional .py files your program brings in with import statements.

"Items" (files) are stored within projects. You can also open files outside projects. When you do this, they are placed in a temporary project called "Miscellaneous Files". You can edit files in temporary projects, but you can't run or debug them until you place the files in a permanent project.

Creating New Projects and Files

Visual Python includes a template for creating new Python projects and programs. When you create a new Python project using the template, the project will include a Python program file with basic code elements.

To create a new Python project:

  1. From the File menu, select New|Project.
  2. Select Visual Python Projects, then select Python Project.
  3. Configure the new project's properties

Related Tutorial Topics: Solutions and Projects 

Configuring Projects

Specify the parameters for running and debugging Python programs inside the associated project. To access the project's properties, right-click the project name in the Solution Explorer window and select Properties.

    Launch Options (these options are applicable to Run and Debug operations)

    • Send these command line arguments to the Python interpreter contains arguments that should be processed by the interpreter when the run or debug functions are invoked.
    • When project is run, start with this script contains the name of the file that is executed when debug or run functions are invoked. By default, the file that is created first is the starting script. Use this field to specify a different starting script.
    • Send these command line arguments to the script: contains input values used by the program during run or debug functions.
    • Run in shell window when this option is selected, run functions will behave as if started from a command-line cmd window. When this option is not selected, the program runs in Visual Studio's Run window.

    Python Options Common Python options can be enabled on this form, rather than manually entering the values in the Send these command line arguments to Python interpreter field on the Launch form.

Related Tutorial Topics: Running Programs  Debugging Programs 

Removing Projects from Solutions

If a project is no longer required by a Visual Studio .NET solution, you can remove it from the solution. This does not delete the project; it simply disassociates it from the solution. To remove a project from a solution:

  1. In the Solution Explorer window, right-click the project name.
  2. Select Remove.

Related Tutorial Topics: Solutions and Projects 

Working with Files

In Visual Studio, it is possible to open a file that is not contained in a project using the folder icon on the standard toolbar. However, you cannot run or debug these files until you add them to a project. For more information on projects, see Configuring Projects.

Adding Files to Projects

To add files to a project:

  1. In the Solution Explorer window, right-click the project name.
  2. If the item already exists on your system, select Add Existing Item..., then navigate to the location of the file.
  3. If you are creating a new item, select Add New Item..., then select a document type and specify a name. By default, new documents will be created in the same directory as the project.

It is not necessary for all files in a project to be located in the same directory; however, if you move the project or associated files, you will have to re-specify file locations.

Installed Python libraries do not need to be made part of a Python project. You can step into Python libraries while debugging; Visual Studio .NET will automatically make them part of a temporary "Miscellaneous Files" project. This project disappears when the solution is closed. The "Miscellaneous Files" project is a generic project, not a Visual Python project, and thus has no configurable Properties.

Removing Files from Projects

To remove a file from a project:

  1. In the Solution Explorer window, right-click the file name.
  2. Select Remove. Note that this does not delete the file; it simply removes the file from the project.

Related Tutorial Topics: Solutions and Projects 

Top

Editing Programs

In this section:

Related Tutorial Topics:

Visual Python supports many features that make writing and editing Python programs easier.

Syntax Coloring

Visual Python supports syntax coloring. Configure colors in the Tools|Options|Environment|Fonts and Colors dialog by selecting the syntactic type and its corresponding color.

Python-specific syntactic types include:

  • Triple quote
  • Class name
  • Function name
  • Operator

Some language elements are common to multiple languages, including Visual Python. Color settings will apply in all languages where these elements are used. Common syntactic types supported by Visual Python include:

  • Comment
  • Identifier
  • Keyword
  • Number
  • String

Related Tutorial Topics: Syntax Coloring 

Syntax Checking

Visual Python's syntax checking function monitors the validity of your code as you type. To enable syntax checking, select Tools|Options|Text Editor|Python|Visual Python Specific, and ensure that the Check syntax while editing box is checked. See Configuring Editor Behavior for more information about configuration options.

When a syntax error is detected, the error is underlined by a red wavy line. If you hover the mouse pointer over the error, an explanatory pop-up tip will describe the nature of the error. Also, the error will be automatically added to Visual Studio's Task List.

Related Tutorial Topics: Syntax Checking 

Method and Module Tips

Method and module tips are pop-up lists of folders, modules, classes, methods or functions displayed according the current context. They are displayed under the following circumstances:

  • following "import" and "from" statements: When you enter a space after an "import" or "from" statement, Visual Studio displays a list of folders and modules found in the system's PYTHONPATH environment variable, and in the current directory. Listed modules include both Python modules and DLLs.
  • following module names: When you enter a period after a module name, Visual Studio displays a list of the classes and functions contained in the module.
  • following classes: When you enter a period after a class name, Visual Studio displays a list of the methods within the class.
  • built-in classes and functions: If you enter Ctrl+j outside of any context listed above, Visual Studio displays Python built-in classes and functions.

To position the list, continue to enter characters until the desired method or module is highlighted, or use the up and down arrow keys to navigate the list. Press Tab or Enter to insert the highlighted method or module. Press Esc to clear the tip. To redisplay the tip, press Ctrl+J.

Related Tutorial Topics: Method Tips 

Call Tips

Call tips are pop-up boxes that display arguments, default values and a brief description for methods and functions. They are displayed when an open parenthesis ("(") follows one of these circumstances:

  • a module name followed by function name
  • a class name followed by method name
  • a variable name followed by method name

Each argument is contained in square brackets; Visual Python bolds each argument in turn as you complete the list of arguments for the given method. Nested tips are supported; that is, if you invoke a method from within a method, call tips for the nested method will be displayed. Press Esc to clear the tip. To redisplay the tip, press Ctrl+Shift+Space, or right-click in the method and select Parameter Info.

Call tips are supported for most built-in Python functions; the exact list varies according to the version of Python that is being used.

Related Tutorial Topics: Call Tips 

Smart Indenting

Smart Indenting automatically indents lines in the editor after colons and open parentheses. To enable Smart Indenting, select Tools|Options|Text Editor|Python|Tabs and ensure that the Smart button is selected in the "Indenting" section.

After a colon, indenting is incremented by the value specified in the Tabs dialog. (To configure the tab characteristics, select Tools|Options|Text Editor|Python|Tabs.)

After an open parenthesis, the editing cursor is indented to the column following the parenthesis on the previous line. When the closing parenthesis is entered, indentation is decremented to the previous position, thus supporting nested constructs.

Related Tutorial Topics: Smart Indenting 

Code Folding

Code folding is used to collapse and expand sections of your Python program. To enable code folding, select Tools|Options|Text Editor|Python|Visual Python Specific, and ensure that the Show code folding box is checked.

Fold points are indicated on the left margin by minus symbols. Visual Python determines fold points by monitoring bracket constructs. When a section of code has been folded, it is indicated by a plus symbol. The folded code can be displayed by hovering the mouse pointer over the ellipses that appear to the right of the first line of the collapsed block. Collapsed code blocks will be automatically opened during debugging or editor-driven modifications.

Related Tutorial Topics: Code Folding 

Commenting Blocks of Code

To comment the currently selected block of code, press Ctrl+K, Ctrl+C or select menu item Edit|Advanced|Comment Selection. Visual Python adds a '#' character to the start of each line in the selection. To uncomment the currently selected block of code, press Ctrl+K, Ctrl+U or select menu item Edit|Advanced|Uncomment Selection. Visual Python removes the first '#' character in each line in the selection.

Related Tutorial Topics: Commenting Blocks of Code 

Adding Entries to the Task List

Visual Studio's Task List is used to maintain a list of outstanding tasks for each Visual Studio solution. To display the Task List, select View|Other Windows|Task List.

Ensure that the Task List is configured to display all tasks. To change the Task List filter, right-click in the Task List pane, and select Show Tasks| All.

Visual Python will automatically add items to the Task List associated with the current solution as follows:

  • Syntax Checking If syntax checking is enabled, syntax errors will be added as items to the Visual Studio Task List. When the syntax error is removed, the entry will be automatically removed from the Task List.
  • TODO Comments Add items to the solution's Task List by entering "TODO" comments in the program in the following format:
      # TODO: comments

Related Tutorial Topics: Task List 

Open a Module in the Editor Pane

When your program uses an external Python module, you can open the module in the editor pane using the Open Document option on the right-mouse context menu. To enable the menu option, right-click while the editing cursor is positioned over the module name.

Related Tutorial Topics: Opening a Module 

Top

Running Programs

Run the "Startup Project" by invoking the menu item Debug|Start Without Debugging (or press Ctrl+F5). In a multi-project solution, the Startup Project's name is displayed in bold text in the Solution Explorer. To run a different project in a multi-project solution, right-click the desired project name in the Solution Explorer and select Set as StartUp Project

To change the options for running a program, right-click the project name in the Solution Explorer and select Properties. See Configuring Projects for information about project properties.

You can run programs in a temporary cmd window, or in the Visual Studio environment. This feature is controlled by selecting or un-selecting Run in shell window field in the Launch form of the Project Properties form. See Configuring Projects for a description of this function.

Running Programs in the Shell Window

To run programs in a temporary cmd window (the "shell window"), enable the Run in shell window check box in the Launch section of the Project Properties. This run behaves as if it were started from a regular shell window. Input is entered in the same manner as on the command line, and sent to the program by pressing the Enter key. To indicate end of input, press Ctrl+Z

Running Programs in the Run Window

If you disable the Run in shell window check box in the project's properties, the program runs in Visual Studio's Run window. If input is required, enter the desired characters and press Enter to proceed. To indicate end of input, press Ctrl+Z

Related Tutorial Topics: Running Programs 

Top

Debugging Programs

In this section:

Related Tutorial Topics:

Visual Python includes a full-featured debugger which you can use to analyze your Python programs.

Start Debug sessions by selecting either the Debug|Step Over (F10) or Debug|Step Into (F11). Do not use Debug|Start to start Visual Python debugger sessions.

Visual Studio .NET provides three visual cues to indicate that the debugger is active:

  • The current line is indicated with a yellow arrow in the breakpoint margin.
  • The debug toolbar is only visible during Debug mode.
  • The menu options and window configuration changes between editing mode and debugging mode. For example, only some of the functions accessible from the Debug|Windows|... menu are visible while you are editing, but all are visible in debugging mode.

Debugger Commands

Debugger commands can be invoked from the Debug menu, from the Debug Toolbar buttons, or by keyboard shortcuts.

  • Debug|Continue (F5) runs the program to the next breakpoint. (If the debugger is not running, this command is called Debug|Start. Do not use Debug|Start to begin Visual Python debugging sessions.)
  • Debug|Step Into (F11) will run the program until the first "executable" line is encountered. The debugger will stop before executing that line. Subsequently, Step Into will execute the line at the current debugger position (indicated by a yellow arrow on the breakpoint margin), advance to the next executable line, and then pause.
  • Debug|Step Over (F10) executes the current line of code. If the current line of code calls a function, method, or procedure, then the function, method, or procedure is executed in the background.
  • Debug|Step Out (Shift+F11) executes the code in a function or method without stepping through the code line by line. Program execution is suspended again on the line of code following the function or method call in the calling program.
  • Debug|Stop (Shift+F5) stops the debugger.

Related Tutorial Topics: Debugging Programs 

Debugger Windows

The following windows are accessible from the Debug|Windows menu during debugging sessions:

Exceptions (Ctrl+Alt+E)
Not applicable to Visual Python
Running Documents (Ctrl+Alt+N)
Not applicable to Visual Python
Autos (Ctrl+Alt+V, A)
Not yet supported
Locals (Ctrl+Alt+V, L)
Proximity variables. These are the variables referenced and/or set in the vicinity of the current line. It's a convenient way of monitoring the program state without having to supply a large number of variable names.
This (Ctrl+Alt+V, T)
Same as the Locals window
Watch (Ctrl+Alt+V, W)
Used to change the value of variables during debugging, to add a variable, and to calculate new values based on variables.
Immediate (Ctrl+Alt+I)
Not yet supported
Call Stack (Ctrl+Alt+C)
Displays the function name, line number and file for each stack frame in the program. You can control whether to show filenames and / or line numbers by right-clicking in the call stack window and checking the corresponding entries.
Threads (Ctrl+Alt+H)
Not yet supported
Modules (Ctrl+Alt+U)
Not applicable to Visual Python

Related Tutorial Topics: Debugging Programs 

Breakpoints

Breakpoints are indicated by red circles on the left margin of the editor pane. Breakpoints have two states: enabled and disabled. Enabled breakpoints are indicated by solid red circles; disabled breakpoints by empty red circles. The debugger will not pause at disabled breakpoints. Breakpoints can be manipulated in several ways:

  • Click the breakpoint margin on the left side of the editor window to set a breakpoint. Click an active breakpoint in order to remove it.
  • Select Debug|Window|Breakpoints (Ctrl+Alt+B) to display the Breakpoint window, where you can add, remove, activate or deactivate breakpoints.
  • Select Debug|New Breakpoint (Ctrl+B) to display the New Breakpoint dialog.
  • Use the right-mouse context menu to add, remove, disable or enable breakpoints.

Related Tutorial Topics: Setting Breakpoints 

Viewing and Changing Variable Values

Visual Python provides a number of ways to watch and modify variables as you debug:

    Locals Window

    The Locals window displays variables referenced and/or set in the vicinity of the current line. To display the Locals window, select Debug|Windows|Locals or use the keyboard shortcut Ctrl+Alt+V, L.

    Watch Window

    Watch Windows are used to view and alter specific variables. To display a Watch window, select Debug|Windows|Watch, and then select a specific Watch window. Alternatively, use the keyboard shortcut Ctrl+Alt+W, number.

    To add a variable to a Watch window:

    • Select the variable in the editor pane, then drag it to the Watch window (or use the right-mouse context menus to copy and paste).
    • Drag the variable from the Locals window to the Watch window (or use the right-mouse context menus to copy and paste).
    • Manually create a new variable by entering the variable name and variable value in the applicable fields.

    To change the name or value of a variable in a Watch window, double-click in the Name or Value field and make the desired changes. You may manipulate variable values by entering arbitrary expressions in the Name field.

    Variable Value Hover Tips

    While the debugger is running, you may view variable values by hovering the mouse pointer over the desired variable. If the variable is unqualified by a period, the value will be displayed in a hover tip. To display the value of interpreted variables, select the entire expression, then hover the mouse pointer over the selected text. The value will be displayed in a yellow hover tip.

Related Tutorial Topics: Viewing and Changing Variables 

Call Stack

The Call Stack displays the name and language of each function that is currently on the stack. To display the Call Stack, select Debug|Windows|Call Stack. By selecting different stacks, you can view the variables (in the Locals windows) particular to each stack. To display the position where the stack changed in the editor pane, double-click the stack in the Call Stack window.

Related Tutorial Topics: Using the Call Stack 

Using the Visual Python Remote Debugger

You can use the remote debugger to open a program on another machine and debug the program using Visual Python. Before you can use Visual Python's remote debugger, however, you must install the Visual Python remote debugging programs on the remote machine. Then you can use the Visual Python debugger on your local machine to debug a remote program.

    Installing the Visual Python Remote Debugger on the Remote Machine

    The Visual Python Remote Debugger is a collection of Python files that must be installed on the remote machine. These files are included as part of your Visual Python installation. You will find the files xmlrpclib.py, korpc.py, kdbxml.py and callvpython.py beneath the root install directory, "ActiveState VisualPython".

    To install the Python Remote Debugger:

    1. Copy the files from the ActiveState VisualPython directory of your local machine to a directory on your remote machine.
    2. On the remote machine, add the directory that contains these files to the PYTHONPATH environment variable.

    Debugging a Standalone Python Script

    Once you have installed the necessary Python programs on the remote computer, you are ready to remotely debug a Python script.

    To debug a standalone Python script:

    1. On the local machine, right-click the project name in the Solution Explorer and select Properties.
    2. Select the Remote Debugging check box. If necessary, specify a port in the Remote port field. Click OK.
    3. Select Debug|Start or F5. The Python Wait Dialog will be displayed, indicating the port number for the process.
    4. Connect to your remote machine and log in.
    5. Run python callvpython.py, and specify the following four items:

    • the hostname, the domain name of the machine on which you are running Visual Python
    • the port number, as configured in the project properties (by default, port 9000)
    • the program name
    • any options for the program

    A connection will be established between the target process (on which callvpython.py is executed) and the Visual Python debugger. From then on, you can make full use of Visual Python's debugging functionality, including setting breakpoints, stepping, viewing the call stack, and watching variables.

    To stop the debugger:

    • From the Debug menu, select Stop Debugging
      or
    • Press Shift+F5

    For example, given the following scenario:

    • Visual Python is running on host mybox.mycompany.com, 
    • the remote port is 9000
    • you want to debug the program spam.py 
    • and pass it the options "eggs -3"

    On the remote machine, you would enter:

    python callvpython.py mybox.mycompany.com 9000 spam.py eggs -3

Related Tutorial Topics: Setting Breakpoints  Viewing and Changing Variables  Using the Call Stack 

Top

Adding Tools to the Visual Studio Tools Menu

You can add tools to the Visual Studio Tools menu to help you program in any supported language. This is a standard Visual Studio feature that is particularly useful for Python programmers.

To add a new tool to the menu:

  1. Select Tools|External Tools|Add...
  2. The dialog prompts you to enter the Title, Command, Arguments, and Initial Directory from which to run the program.

To access a tool:

  • Select Tools|External Tools| and select the desired tool.
Top

Using the Class View

Visual Studio's Class View (also known as the Class Browser) is used to quickly navigate files, classes and functions in the programs contained in the current Visual Studio solution. To open the Class Viewer, select View|Class View (Ctrl+Shift+C).

The Class View, by default, arranges items in a hierarchical manner. Double-click an item in the Class View window to position the display in the editor pane to the desired item. For more information, see the Visual Studio documentation.

Top

Using the Python Interactive Shell

Visual Python provides an interactive shell that makes it more convenient to test snippets of code before adding them to your programs. The Python Interactive Shell offers code coloring and cut-and-paste functionality.

To open the Python Interactive Shell, select View|Other Windows|Python Interactive Shell.

The Python Interactive Shell window can be resized and docked. Use the "New Session" icon in the top left corner of the window to clear any existing code.

Top

Documentation

In this section:

Related Tutorial Topics:

Dynamic Python Help

Visual Python takes advantage of Visual Studio's Dynamic Help system to provide context-sensitive language reference for Python.

To display the Dynamic Help pane, select Help|Dynamic Help. The Dynamic Help pane is displayed as a component of the Visual Studio workspace, similar to the Solution Explorer, and can be relocated and resized as desired.

As you type in the Visual Studio editor, the Dynamic Help pane, under the Help heading, displays links to the Python language reference. The links are context sensitive; for example, after typing the term "print" in the editor, the term "print" will appear in the Dynamic Help pane with a link to the relevant documentation. To view the entire document set, select the link Python Language Overview from the Dynamic Help pane, or select Help|Contents|ActiveState Visual Python|Python Language Reference.

Related Tutorial Topics: Dynamic Help 

Visual Python Documentation

The Visual Python User Guide (this document), Release Notes and Tutorial are integrated into the Visual Studio Help system. To access these documents, select Help|Contents, and select ActiveState Visual Python from the contents menu. The documents are fully searchable using Visual Studio's Search functionality (Help|Search).

The Visual Python User Guide, Release Notes and Tutorial are also deployed in standard HTML format. To view, select Start|Programs|ActiveState Visual Python, and then choose the document you wish to view.

Related Tutorial Topics: Dynamic Help 

Top

Visual Python FAQ

How do I debug a Python program?

    To debug a Python program, the program must be contained in a Visual Studio Project, which, in turn, is contained in a Visual Studio Solution. You cannot debug python programs that are not contained in a project and solution. See About Solutions and Projects for further information.

    To start debugging, open the solution that contains the project and program, then open the program itself. Select Debug|Step Over (F10) or Debug|Step Into (F11) to start debugging. Set breakpoints by clicking in the breakpoint margin to the left of the workspace, or use the Breakpoints window (Debug|Window|Breakpoints) to view and manipulate all breakpoints. For further information, see Debugging Programs

My code lines are not indenting properly. How do I fix this?

    Confirm that the Smart Indent option is selected for the Python editor. On the Tools menu, select Options, then click the Text Editor folder. Click Python, then click Tabs. In the Indenting section, ensure that "Smart" is selected. Also, ensure that your Tab and Indent sizes are not set to zero.

How do I set command-line parameters?

    In the Solution Explorer window right-click the project name, select Properties, and fill in the information on the Launch and Python Options tabs. See Configuring Projects for further information about project properties.

I opened a Python program in the editor. It's nicely colored, but I don't see how to debug it. Why not?

    If you can't access the Debug|Start or Debug|Start Without Debugging menu items, you probably opened up the file outside a project. You need to work within projects to run or debug programs. Please see the sections on Debugging Programs and Running Programs for more information.

I accidentally closed the cmd window while the debugger was running. What do I do now?

    This triggers error messages, such as a dialog box stating "An existing connection was forcibly closed by the remote host. Press OK." This can cause the PythonDebugger.exe (Python~1.EXE) program to halt, so first close the debugging session with the menu item Debug|Stop Debugging (Shift+F5). You may also need to launch the Task Manager to close the debugging session. See the FAQ item below for instructions on ending the debugger process using the Windows Task Manager.

The debugger is reporting that there was no initial stopping location in the program. Why?

    Visual Python doesn't know how to debug programs without executable statements, because there is no breakpoint for the debugger to stop at. This triggers an error message stating that there was no initial stopping location in the program. Click OK to continue.

The debugger appears to be stuck in debug mode, or will not begin debugging. How do I fix it?

    If you find that Visual Python refuses to debug programs, or is stuck in a debugging mode, open the Windows Task Manager, select the Processes tab, then click the Image Name column header to sort the processes by name. End the Python~1.EXE process; this will close the debugger and the target Python program.

I have installed Visual Python, but Python editing support and debugging functions are not working. What should I do?

    When you load Visual Studio .NET, you should see the Visual Python logo on the banner that displays while the program loads. If the logo does not display, Visual Python did not correctly register itself with Visual Studio during the installation, and editing and debugging support for Python will not be available. To manually register Visual Python, follow these steps:

    1. Open a DOS command window. On most systems this is accessible from Start|Programs| Accessories|Command Prompt.
    2. Change directory to C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE.
    3. Run devenv/setup.

    Launch Visual Studio .NET again. If the Visual Python logo still fails to display, contact the Visual Python Feedback mailing list.

During debugging, I get the error 'Not enough storage is available to process this command'. Why?

    If Visual Python is installed by a user with Administrative rights, it must also be run by a user with Administrative rights. If you attempt to run Visual Python while logged in as a user with less than Administrative rights, the user account will be unable to access privileged resources in the system registry, and therefore Visual Python will generate errors.

How do I add an entry to this list?

Top

Contact ActiveState

Visual Python Announcements: to receive announcements via email regarding Visual Python, subscribe to the Visual Python Announcement list. See the Visual Python Announcement Message Archive to view previous notices.

Visual Python Discussions: to participate in email discussions regarding Visual Python, subscribe to the Visual Python Discussion list. See the Visual Python Discussion Message Archive to view previous discussion threads.

Visual Python Questions and Comments: send email to the Visual Python Feedback mailing list.

Visual Python Bugs: to view and report Visual Python bugs, visit the Visual Python bug database.

Top

 

 


Copyright © 2000 - 2005 ActiveState, a division of Sophos Plc. Portions Copyright © 1987-2003, Microsoft Corporation. All rights reserved. ActiveState and Visual Python are registered trademarks of ActiveState Corporation. IntelliSense® is a Registered Trademark of Microsoft. Other companies and products mentioned in this document are the property of those companies.


Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved