‏إظهار الرسائل ذات التسميات python. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات python. إظهار كافة الرسائل

الجمعة، 27 ديسمبر 2013

how to get a list from C# code into a list in python

I have a C# DLL that I am calling in python and one of its methods returns what should be like a list

this code works

data =[0,1]ch=['VCC_CORE0','VCCSFR']data[0],data[1] = myDaqControl.SpyMulti(ch)

but I am trying to make it dynamic don't want to add the list arguments at the start because in this example I have ch = 2 variables but next time it can be 5 or 10

so typing data[0],data[1]..... doesn't make sense

doing data = myDaqControl.SpyMulti(ch) doesn't work and I get from interpreter is:

i found out the the C# code should be returning an Array

additional code priore to what i mentioned

import clrimport sysimport timeitimport timeChannel ='Iin_P1'ConfigFile='c:\NiDaq_spy.xml'start_time = time.time()sys.path.append(r'C:\daq\Bin')clr.AddReference('DaqBase.Factory')from Daq import DaqControlFactoryfrom Daq import IDaqControlmyDaqControl = DaqControlFactory.GetDaqControl("NiDaq")

View the original article here

الثلاثاء، 24 ديسمبر 2013

Non-ASCII chars in python file deletes other chars

Turns out the locale had to be set to sv_SE.utf8 rather than sv_SE or sv_SE.UTF-8. If you're from another country than Sweden (which statistically seems reasonable to assume) you obviously have to find the right locale name for your language and location.

Then just do this to generate (optional) your locale, and set it:

locale-gen sv_SE.utf8locale-update LANG=sv_SE.utf8reboot

Replace LANG for any other environment variables you need to set. This will create/modify the file /etc/default/locale.


View the original article here

python multiprocess fails to start

Here is my code for a simple multiprocessing task in python

from multiprocessing import Processdef myfunc(num): tmp = num * num print 'squared O/P will be ', tmp return(tmp)a = [ i**3 for i in range(5)] ## just defining a listtask = [Process(target = myfunc, args = (i,)) for i in a] ## creating processesfor each in task : each.start() # starting processes <------ problem linefor each in task : each.join() # waiting all to finish up

When I run this code, it hangs at certain point, so to identify it I ran it line by line in python shell and found that when I call 'each.start()' The shell pops out a dialogue box as:

" The program is still running , do you want to kill it? '

and I select 'yes' the shell closes.

When I replace Process with 'threading.Thread' the same code runs but with this nonsense output:

Squared Squared Squared Squared Squared 0 149162536496481

Is there any help in this regard ? thank in advance


View the original article here