s = Simple(10)
print s
IronPython 输出:
>>> s = Simple(10)
>>> print s
Simple>> import clr
>>> clr.AddReferenceToFile("csextend.dll")
>>> import Simple
>>> dir(Simple)
>>> s = Simple(10)
>>> for i in s: print i
Simple import Simple
>>> dir(Simple)
>>> a = Simple(10)
>>> b = Simple(20)
>>> a + b
>> import clr
>>> clr.AddReferenceToFile("vbextend.dll")
>>> import Simple
>>> a = Simple(10)
>>> def X(i):
... return i + 100
...
>>> a.Transform(X)
110
Tutorial 总结
csextend.cs 和 vbextend.vb 文件的完整版本位于Tutorial路径下,与这两个文件在一起的还有
csxtest.py 和vbxtest.py 两个文件。而后面的这两个文件就是相应的C# 与 Visual Basic .NET扩展
测试代码.
The code to experiment with debugging of Python and C# or Visual Basic code, use Python scripts debugcsx.py and debugvbx.py respectively.
本tutorial 中您做了如下练习.
Tutorial 6: 使用Visual Studio 编辑“.py”文件并进行调试
除了.NET的调试支持之外,Visual Studio也支持简单地编辑“.py”文件(no coloring or expression
completion). 本tutorial 告诉您如何用Visual Studio 配置 Python 脚本工作.(This tutorial shows
you how to quickly set up Visual Studio to work on Python scripts in a directory.)
在属性对话框中, 添加两个属性:命令行参数(Command Arguments)和工作路径(Working Directory).
在命令行参数(Command Arguments)中, 敲入"first.py". 在工作路径(Working Directory)中, 敲入Tutorial
路径(c:"IronPython"Tutorial" is where we assume you have it). 单击应用和“OK”确认修改.
现在使用“File->Save All ... ”命令保存修改. 保存它到Tutorial 路径.
为了了解更多的步骤 (stepping), 我们对这个文件添加一行并设置另一个断点. 在文件底部添加
一行并调用factorial 函数("factorial(5)"). 在行reads "if n < 1: return 1" 添加断点. 现在按下F5
运行脚本. 反复按下F10 观察“locals window” 参数 "n" 减少到 0 。then goes back up to 5 as the
recursion unwinds. 您也可以将鼠标放在 "n" 上面, 每次运行到断点处暂停时,得到该变量的数据提示.
为了运行其它脚本, 只要修改“ipy.exe”项目的命令参数,以及其它的script. 您可能也看到“工具->
选项”对话框,改变“环境->文档”上的属性来显示打开的脚本文件. 如选择"Show Miscellaneous Files
in the Solution Explorer", 然后您会得到正在编辑的“.py”文件列表. 以后每次您打开这个解决方案时,
您会看到解决方案下所有开发的“.py”文件.
Tutorial 总结:
本tutorial 中,您做了如下练习.
Setting up Visual Studio for IronPython Debugging,配置Visual Studio 用于IronPython 调试
本tutorial 中,您配置Visual Studio 运行 Python scripts 脚本并调试它们.