ironpython

Python - test a property throws exception

故事扮演 提交于 2020-07-18 03:56:50
问题 Given: def test_to_check_exception_is_thrown(self): # Arrange c = Class() # Act and Assert self.assertRaises(NameError, c.do_something) If do_something throws an exception the test passes. But I have a property, and when I replace c.do_something with c.name = "Name" I get an error about my Test Module not being imported and Eclipse highlights the equals symbol. How do I test a property throws an exception? Edit: setattr and getattr are new to me. They've certainly helped in this case, thanks.

Optimizing Python scripts' running time from C#

佐手、 提交于 2020-07-10 07:34:08
问题 I apologize in advance if my question is badly formulated, for I don't know if what I need makes any sense. I'm currently working on a c# project where I need to run several time the same python script from inside the program, but with different arguments each time. For this, I'm not using IronPython, but the ProcessStartInfo class, for I understood that IronPython has some problem with certain packages I use. But this can change. My problem is that although the python script is small and

Python - “KeyError : System.Object” - Pyadomd - Querying a SSAS Data Source [SOLVED]

半世苍凉 提交于 2020-06-01 05:10:48
问题 Working on a project where I am trying to query a SSAS data source we have at work through Python. The connection is presently within Excel files, but I am trying to reverse engineer the process with Python to automate part of the analysis I do on a day to day... I use the pyadomd library to connect to the data source, here`s my code: clr.AddReference(r"C:\Program Files (x86)\Microsoft Office\root\vfs\ProgramFilesX86\Microsoft.NET\ADOMD.NET\130\Microsoft.AnalysisServices.AdomdClient.dll") clr

Docker issue: /bin/sh: pip: not found

对着背影说爱祢 提交于 2020-05-28 13:52:32
问题 So my dockerfile is : FROM iron/python:2.7 WORKDIR /app ADD . /app RUN pip install --upgrade pip RUN pip install -r ./requirements.txt Recently though when I build my image with: docker build --no-cache -t <image name>:<tag> I run into the issue of: Step 4/6 : RUN pip install --upgrade pip ---> Running in 00c781a53487 /bin/sh: pip: not found The command '/bin/sh -c pip install --upgrade pip' returned a non-zero code: 127 was there any changes to docker that might have caused this? Because

Capture python print statements in C#

拈花ヽ惹草 提交于 2020-05-14 08:58:09
问题 I am writing a C# component which takes an ironpython function as a parameter. def test(): x=x+1 print "Test" C#: var v = engine.Operations.Invoke(scope.GetVariable("test")); Var v returns null for print statements. It works only if I have return(x) . Can I capture print statements using ironpython? Comments and links are appreciated. Also, can just capture it using commandline? 回答1: This works for me: using IronPython.Hosting; using Microsoft.Scripting.Hosting; //provides scripting abilities

C# DynamicObject 动态对象

六月ゝ 毕业季﹏ 提交于 2020-05-06 06:50:02
dynamic是FrameWork4.0的新特性。dynamic的出现让C#具有了弱语言类型的特性。编译器在编译的时候不再对类型进行检查,编译期默认dynamic对象支持你想要的任何特性。比如,即使你对GetDynamicObject方法返回的对象一无所知,你也可以像如下那样进行代码的调用,编译器不会报错: dynamic dynamicObject = GetDynamicObject(); Console.WriteLine(dynamicObject.Name); Console.WriteLine(dynamicObject.SampleMethod()); dynamic与var关键字本质区别 var只能用作局部变量,不能用于字段,参数;声明的同时必须初始化;初始化时类型就已经确定了,并且不能再被赋值不能进行隐式类型转换的类型的数据。 var实际上是编译期抛给我们的“语法糖”,一旦被编译,编译期会自动匹配var 变量的实际类型,并用实际类型来替换该变量的申明,这看上去就好像我们在编码的时候是用实际类型进行申明的。 dynamic可用于类型的字段,方法参数,方法返回值,可用于泛型的类型参数等;可以赋值给或被赋值任何类型并且不需要显式的强制类型转换,因为这些是运行时执行的,这要得益于dynamic类型的动态特性。 dynamic被编译后,实际是一个object类型

01 . Python简介

≯℡__Kan透↙ 提交于 2020-04-28 12:44:59
Python简介 计算机语言 人与计算机之间交互的语言 机器语言 一定位数组合二进制的0和1的序列,被称为机器指令,机器指令的集合就是机器语言 与自然语言差异太大、难学、难懂、难记、难差错. 汇编语言 用一些助记符号替代机器指令,称为汇编语言,ADDA,B指的是将寄存器A的数与寄存器B的数相加得到的数放到寄存器A中. 汇编语言写好的程序需要汇编程序转换成机器指令 汇编语言只是稍微好记了写,可以认为就是机器指令对应的助记符,只是符号本身接近自然语言. 程序 算法+数据结构=程序 数据一切程序的核心 数据结构是数据在计算机中的类型和组织方式. 算法是处理数据的方式,算法有优劣之分. 写程序难点 理不清数据 搞不清处理方法 无法把数据设计转换成数据结构,无法把处理方法转换成算法. 无法用设计范式来进行程序设计. 世间程序皆有bug,但不会debug。 Python解释器 官方CPython C语言开发,最广泛的解释器 IPython 一个交互式、功能增强的Cpython PyPy Python语言编写的Python解释器,JIT技术,动态编译Python代码 Jython Python的源代码编译成Java的字节码,跑在JVM上 IronPython 与Jython类似,运行在.Net平台上的解释器,Python代码编译成.Net的字节码. Python语言类型 Python是动态语言

【Python3 爬虫】U29_GIL全局解释器锁

自古美人都是妖i 提交于 2020-04-09 01:14:18
Python自带的解释器是CPtyhon。CPtyhon解释器的多线程实际上一个假的多线程(在多核CPU中,只能利用一核,不能利用多核)。同一时刻只有一个线程在执行,为了保证同一时刻只有一个下线程在执行,在CPython解释器中有一个东西叫做GIL,叫做全局解释器锁。这个解释器锁是有必要的,因为CPython解释器的内存管理不是线程安全的。当然,处理CPython,还有其他解释器: 1.Jython,用Java实现的解释器。不存在GIL锁。 2.IronPython:用.net实现的Python解释器。不存在GIL锁。 3.PyPy:用Python实现的Python解释器。存在GIL锁。 GIL虽然是一个假的多线程。但是在处理一些IO操作上(例如写文件和网络请求),可以很大程度的提高效率。在IO密集型操作上建议使用多线程,但是在一些CPU密集型操作上不建议使用多线程,而建议使用多进程。 来源: oschina 链接: https://my.oschina.net/u/4300877/blog/3225205

robot framerk -String

核能气质少年 提交于 2020-03-24 16:20:46
3 月,跳不动了?>>> String Library version: 3.0.4 Library scope: global Named arguments: supported Introduction A test library for string manipulation and verification. String is Robot Framework's standard library for manipulating strings (e.g. Replace String Using Regexp , Split To Lines ) and verifying their contents (e.g. Should Be String ). Following keywords from BuiltIn library can also be used with strings: Catenate Get Length Length Should Be Should (Not) Be Empty Should (Not) Be Equal (As Strings/Integers/Numbers) Should (Not) Match (Regexp) Should (Not) Contain Should (Not) Start With

Unity 捕获IronPython脚本错误

北战南征 提交于 2020-03-23 13:10:01
版权声明:本文为博主原创文章。未经博主同意不得转载。 https://blog.csdn.net/akof1314/article/details/36048747 捕获的方法摘自《 IronPython in Action 》一书,代码例如以下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145