Re: Problems with Python for Windows extensions
Hello, I guess you could reproduce my problem, Kartic. I have tried the one u suggested, but sadly it didn't work for me. I think the COM of pywin is quite tricky, or it might be a bug. I have some friends who also had experience of weird behaviors of pywin32, which makes me skeptical of using it in real app. Thanks KK -- http://mail.python.org/mailman/listinfo/python-list
Problems with Python for Windows extensions
the code below is taken from M$ technet as an example on using vb script to do a replace all in word: Const wdReplaceAll = 2 Set objWord = CreateObject(Word.Application) objWord.Visible = True Set objDoc = objWord.Documents.Open(K:\Development\Fabricbase\prod\Test.doc) Set objSelection = objWord.Selection objSelection.Find.Text = Contoso objSelection.Find.Forward = True objSelection.Find.MatchWholeWord = True objSelection.Find.Replacement.Text = Fabrikam objSelection.Find.Execute ,,wdReplaceAll I did a rewrite and made it pythonic: from win32com.client import * wdReplaceAll = 2 objWord = Dispatch(Word.Application) objWord.Visible = True objDoc = objWord.Documents.Open(K:\Development\Fabricbase\prod\Test.doc) objSelection = objWord.Selection objSelection.Find.Text = Contoso objSelection.Find.Forward = True objSelection.Find.MatchWholeWord = True objSelection.Find.Replacement.Text = Fabrikam objSelection.Find.Execute (Replace = wdReplaceAll) However, the document juz loaded up in word but no action was taken. I am using Word 2003. Any ideas? -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with Python for Windows extensions
thx for ur reply u r rite that i should use a raw string, but that doesn't solve the problem i am q annoyed by this strange behaviour. i tried to run the script on my friend's pc, which is python2.4 + pywin 204 + office 2000, but same thing happened now i am thinking to generate a vbs from python and run it. i know it is dumb but i dont know other solutions... -- http://mail.python.org/mailman/listinfo/python-list
Creating alot of class instances?
Hi I am new to Python classes and trying to figure out this particular issue here. I will need to create instances of a class. But at the moment I do not know how many instances I will end up having, in every case it might be different. Most of the documents I read makes this simpl class-student analogy to explain python classes which is fine. But in those examples the number and the names of the instances were known and limited. I will be querying some data and create class instances based on the data I gather. But the problem as I mentioned is that I do not know the names and the number of the end class instances. They will be based on the content of the data. So how can I create class instances within a loop and when the loop is done how can I figure out the list of instances via class membership? I can track the names by introducing another list but I want to understand the class side of things. The solution might be dead simple but I just cannot figure out at the moment. For example this is what I need in the simplest form class myclass(): def __init__(self,name): self.name=name for count,data in enumerate(some list): instance_count=myclass() instance_count.name=data print instances thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating alot of class instances?
Hi Thank you soo much for speedy and in detailed help. Your replies really cleared out most of the cloud for me. I have one last issue to resolve which is something I did not articulate properly, I realize now. The last issue is actually automatically naming the instances. The reason I was using the instance_count is for enumerating the actual name of an instance. For example lets say I have class MyMaterials: and my instances might need to look like material_01 material_02 or light_01 light_02 or Mesh_01 Mesh_02 etc I will need to get the base names from the some list and create the names accordingly from the list array. Basically I also need to generate the instance names based on the some list. For example some_list[2] might denote a name for the instance. I will study the sampled codes in depth now. Maybe you have answered the naming issue as well, if so please frgove the noise. thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating alot of class instances?
Hi Thank you so much for wonderful tips and suggestions. I also found a solution to dynamic naming of the instances(I think). It does not sound like a very secure method but since my application will be just processing data one way I think it might be alright. I will compare to the list and dictionary methods. globals()[Some_Instance_Name] -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating alot of class instances?
Steven, Before your post I was contemplating about the merits of using the globals(). After reading your post I am totally convinced that your suggestion that was also suggested by previous posters is the way to go. At first I thought it would be limiting to not to have the instance names properly setup, but now I understand it better. thank you all again. -- http://mail.python.org/mailman/listinfo/python-list
How can I get the line number ?
Hello I am writing some Python code that runs in another application(has wrapper functions). Due to lack of debugging I am printing out alot of outputs and manual messages. I want to be able to create a function that would let me print the current line number that is called from. This is not for debugging exceptions it is rather to simplify my debug messages, at least I can trace my debug messages. thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I get the line number ?
Maxim, Thank you so much. I will try right now. -- http://mail.python.org/mailman/listinfo/python-list
Re: pylucene installation problem on Ubuntu 9.04
On Aug 7, 12:38 am, Jon Clements jon...@googlemail.com wrote: On 6 Aug, 19:49, KK dioxide.softw...@gmail.com wrote: hi all, I've trying to install pylucene on my linux box from last 2 days but not able to do so. first i tried to install it using apt-get like this, kk-laptop$ sudo apt-get install pylucene and it did install python2.5, python2.5-minimal and pylucene. I must mention one thing that I already had python2.6 on my box as the default python i.e /usr/bin/python is linked to python2.6. Anyway s, now i started the python interpreter using python command from cli and then to make sure pylucene has been installed i tried to import the module and to my surprise it said module pylucene not found. I thought I should enter the python2.6 env and do the same , so i tried starting the python2.6 interpreter using python2.6 as the command and tried importing the same module and again it failed giving the same irritating message. As a final try i pulled the source code of pylucene and as per the comments given there in the README file, copied the mentioned files to site-packages directory of python2.6 and then tried importing the module and then got the same error message saying no module name pylucene is present. I'm sick of this error ! Can someone point me what is the issue? If it is due to multiple version of python running on box, can someone tell me which one to remove or someone tell me how to get the whole thing running? I'll very much thankful to you guys. Thanks, KK. If you installed using apt, have you a pylucene directory under /usr/ local/lib/python2.6/dist-packages/? Also, if you run python, and import sys; print sys.path whats it show? Jon. Yes I've a dirctory called dist-packages under python2.6 but that doesn't contain anything on pylucene [it has lupyne, which i installed day before yesterday and importing lupyne doesn't give any error msg, but again it is dependent on pylucene] # for python the output is : -- kk-laptop$ python Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. import sys print sys.path ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/ python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/ lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/ dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/ lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/ gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/ python2.6/dist-packages'] --- for python2.5 this is the output: kk-laptop$ python2.5 Python 2.5.4 (r254:67916, Apr 4 2009, 17:55:16) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. import sys print sys.path ['', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/ python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/ python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/ lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/ gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/ site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0'] and for python2.6 the output is this: kk-laptop$ python2.6 Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. import sys print sys.path ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/ python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/ lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/ dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/ lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/ gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/ python2.6/dist-packages'] From all of the above what I can see is we don't have any directory named dist-packages under python2.5 but we've one under 2.6, then where did all those pylucene files got installed to after i installed it using apt-get? Any ideas? Thanks KK -- http://mail.python.org/mailman/listinfo/python-list
Re: pylucene installation problem on Ubuntu 9.04
I tried doing something silly. I went to the directory /usr/local/lib/python2.6/site-packages and then tried to compile/run the file called PyLucene.py the way we compile/run python scripts, then from there i started the python interpreter by typing python ( which is actually python2.6), then i tried to import that module, [un]fortunately it din't give that error message but something else, you can see below: kk-laptop:/usr/local/lib/python2.6/site-packages$ python Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. indexDir = '/opt/lucene/index' import PyLucene WARNING: could not properly read security provider files: file:///usr/local/gcc-3.4.6/lib/security/libgcj.security file:///usr/local/gcc-3.4.6/lib/security/classpath.security Falling back to standard GNU security provider then tried to copy and paste my sample code for indexing data to lucene, this way: writer = IndexWriter(indexDir, StandardAnalyzer(), True) title = this is sample page title content = This is sample page content for testing pylucene tool doc = Document() doc.add(Field(title, title, Field.Store.YES, Field.Index.TOKENIZED)) doc.add(Field(content, content, Field.Store.YES, Field.Index.TOKENIZED)) writer.addDocument(doc) writer.optimize() and surprisingly it din't give any other error. to crosscheck things i went to the lucene index directory and fired LUKE and luckily found that doc being indexed by lucene, even i tried searching for some words and found they are working fine. So Pylucene seems to be working partially, in my case. But I think python is not able to load the PyLucene module (btw, i din't see any __init__ scripts which, i guess, are used for bootstrapping external modules, right?). Then what is the fix for this? do we have to add some __init__ scripts to make python load PyLucene module when it starts? do i sound silly? What is the best/easiest way to get this working? I've spend quite a lot of time jsut to make PyLucene running but to no avail. BTW, I tried to start the python interpreter from other locations and tried imporitn this PyLucene module but got the same irritating error message saying module not found. Also trying to run my sample indexer from cli using the normal way[kk- laptop$ python indexer.py] gave the same error message. Any help/advice is highly appreciated. Thanks, KK On Aug 7, 8:22 am, KK dioxide.softw...@gmail.com wrote: On Aug 7, 12:38 am, Jon Clements jon...@googlemail.com wrote: On 6 Aug, 19:49, KK dioxide.softw...@gmail.com wrote: hi all, I've trying to install pylucene on my linux box from last 2 days but not able to do so. first i tried to install it using apt-get like this, kk-laptop$ sudo apt-get install pylucene and it did install python2.5, python2.5-minimal and pylucene. I must mention one thing that I already had python2.6 on my box as the default python i.e /usr/bin/python is linked to python2.6. Anyway s, now i started the python interpreter using python command from cli and then to make sure pylucene has been installed i tried to import the module and to my surprise it said module pylucene not found. I thought I should enter the python2.6 env and do the same , so i tried starting the python2.6 interpreter using python2.6 as the command and tried importing the same module and again it failed giving the same irritating message. As a final try i pulled the source code of pylucene and as per the comments given there in the README file, copied the mentioned files to site-packages directory of python2.6 and then tried importing the module and then got the same error message saying no module name pylucene is present. I'm sick of this error ! Can someone point me what is the issue? If it is due to multiple version of python running on box, can someone tell me which one to remove or someone tell me how to get the whole thing running? I'll very much thankful to you guys. Thanks, KK. If you installed using apt, have you a pylucene directory under /usr/ local/lib/python2.6/dist-packages/? Also, if you run python, and import sys; print sys.path whats it show? Jon. Yes I've a dirctory called dist-packages under python2.6 but that doesn't contain anything on pylucene [it has lupyne, which i installed day before yesterday and importing lupyne doesn't give any error msg, but again it is dependent on pylucene] # for python the output is : -- kk-laptop$ python Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type help, copyright, credits or license for more information. import sys print sys.path ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/ python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/ lib-dynload', '/usr/lib/python2.6
Why does my ftp script quit after couple of hours?
Hi This way the first time I did something with ftp stuff. I think that generally it works but it stops working(quits or disappears) after couple of hours of running. This was a personal test-trial script for my own needs which was to get my dynamic ip and broadcast to a client(I have a client script on another computer). I sure could use something like DynDns for the same purpose with easier management but I just wanted to give it a try to see if i could even make it work . Basically this script parses my ip from DynDns ip check page and uploads it to the given ftp site. It works fine initially, it does upload, it updates the Ip every hour but the problem is that after couple of hours the Python console window disappears, I assume it crashes. I know it does upload at least couple times(works for couple hours). it might be something to do with ftp connection. I will investigate that but I just wanted to see if I have any logic or some kind of contextual problem in the script. Here is the link to Pastie page http://pastie.org/584152 Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does my ftp script quit after couple of hours?
Hi Diez Thanks for your insight. The reason I chose the awkward method to parse the ip digits is that I was not familiar with the regex module and the Dyndns Ip page is pretty simple page. I guess it is time to learn more about the Re module. As far as robustness, I agree with your assestment. I guess my main confusion with my result is that the console window just disappears. I wonder if I can make the window stay even if it crashesor if there are connection issues? I will createa seperate log file to see if I can catch any issues in a log file. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does my ftp script quit after couple of hours?
Awesome stuff, thank you so much for all the help. The Pcomp.lang.python is the most helpful list I have encountered so far :) -- http://mail.python.org/mailman/listinfo/python-list
How to import modules from specific Python installation?
Hi I know there is a way to import from different Python installation but I could not find the answer. I have Python 2.6 and 2.5 thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: How to import modules from specific Python installation?
Hi Thank you for the suggestions, I will see what I can from here. -- http://mail.python.org/mailman/listinfo/python-list
Returning dictionary from a function
Hi I am working on something here and I cannot get the full dictionary out of a function. I am sure I am missing something here. Anyways here is a simple code that repeats my problem. Basically I am just trying to get that values function to return the diky as a dictionary so that I can query values later. thanks def values(x): diky={} for a in range(x): a=a+100 diky={chr(a):a} print diky return diky b=values(5) print type(b),len(b), b['f'] # gives error print type(b),len(b), b['h'] # does not give error -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning dictionary from a function
Btw my main problem is that when I assign the function to 'b' variable I only get the last key from the dictionary. Sorry about that I forgot to mention the main issue. -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning dictionary from a function
Hi Thank you so much. It makes perfect sense. I actually tried the second suggested syntax before posting here but it was inside of my actual code which probably had another problem. The suggested solution works perfectly. thanks again -- http://mail.python.org/mailman/listinfo/python-list
Re: Returning dictionary from a function
John, Thanks for pointing out the loop issue. I just typed these sloppy lines the demonstrate the issue, they were not part of any code by any means. I will make sure that I will post cleaner lines next time. -- http://mail.python.org/mailman/listinfo/python-list
PyQt
I have python 3.2 installed m not able to install PyQt. i have downloaded and configured sip but how to build it??? whats the make and make install given on the installation Plzzz help m a newbie to python -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt
Thanks for the reply!! i ve installed the binary but when i import anything of PyQt in my prog it says error?? i think there is some problem with folders -- http://mail.python.org/mailman/listinfo/python-list
Fast Python in Programming Contests
How can the execution time of python program be increased in programming contest so that we dont get TLE for gud algos.. -- http://mail.python.org/mailman/listinfo/python-list
python script for monitoring input/output parameters of online gaming client
Hi, I'd like to be able to capture parameters of online gaming client applications (the kind of client software you install to play poker, backgammon... online) with the aim of writing python software that analyzes this data. I'm clueless, as I know next to nothing about python networking. Could anyone please point out in what direction I should look to solve this, what libraries I should look at, etc. ? Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
python script for monitoring input/output parameters of online gaming client
Hi, I'd like to be able to capture parameters of online gaming client applications (the kind of client software you install to play poker, backgammon... online) with the aim of writing python software that analyzes this data. I'm clueless, as I know next to nothing about python networking. Could anyone please point out in what direction I should look to solve this, what libraries I should look at, etc. ? Thanks a lot. -- http://mail.python.org/mailman/listinfo/python-list
list comprehension return a list and sum over in loop
Hi there, The list comprehension is results = [d2(t[k]) for k in xrange(1000)], where d2 is a function returning a list, say [x1,x2,x3,x4] for one example. So results is a list consisting of 1000 lists, each of length four. Here, what I want to get is the sum of 1000 lists, and then the result is a list of length four. Is there any efficient way to do this? Because I found it is slow in my case. I tried sum(d2(t[k]) for k in xrange(1000)), but it returned error: TypeError: unsupported operand type(s) for +: 'int' and 'list'. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: list comprehension return a list and sum over in loop
Mark Lawrence於 2014年12月12日星期五UTC+8下午3時17分43秒寫道: On 12/12/2014 06:22, KK Sasa wrote: Hi there, The list comprehension is results = [d2(t[k]) for k in xrange(1000)], where d2 is a function returning a list, say [x1,x2,x3,x4] for one example. So results is a list consisting of 1000 lists, each of length four. Here, what I want to get is the sum of 1000 lists, and then the result is a list of length four. Is there any efficient way to do this? Because I found it is slow in my case. I tried sum(d2(t[k]) for k in xrange(1000)), but it returned error: TypeError: unsupported operand type(s) for +: 'int' and 'list'. Thanks. I think you need something like this http://stackoverflow.com/questions/19339/a-transpose-unzip-function-in-python-inverse-of-zip I'll let you add the finishing touches if I'm correct :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence Hi Mark and Yotam, Thanks for kind reply. I think I didn't make my problem clear enough. The slow part is [d2(t[k]) for k in xrange(1000)]. In addition, I don't need to construct a list of 1000 lists inside, but my aim is to get the sum of all d2(t[k]). I wonder if there is any method to sum up efficiently. -- https://mail.python.org/mailman/listinfo/python-list
Re: list comprehension return a list and sum over in loop
Peter Otten於 2014年12月12日星期五UTC+8下午5時13分58秒寫道: KK Sasa wrote: Mark Lawrence於 2014年12月12日星期五UTC+8下午3時17分43秒寫道: On 12/12/2014 06:22, KK Sasa wrote: Hi there, The list comprehension is results = [d2(t[k]) for k in xrange(1000)], where d2 is a function returning a list, say [x1,x2,x3,x4] for one example. So results is a list consisting of 1000 lists, each of length four. Here, what I want to get is the sum of 1000 lists, and then the result is a list of length four. Is there any efficient way to do this? Because I found it is slow in my case. I tried sum(d2(t[k]) for k in xrange(1000)), but it returned error: TypeError: unsupported operand type(s) for +: 'int' and 'list'. Thanks. I think you need something like this http://stackoverflow.com/questions/19339/a-transpose-unzip-function-in-python-inverse-of-zip I'll let you add the finishing touches if I'm correct :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence Hi Mark and Yotam, Thanks for kind reply. I think I didn't make my problem clear enough. The slow part is [d2(t[k]) for k in xrange(1000)]. In addition, I don't need to construct a list of 1000 lists inside, but my aim is to get the sum of all d2(t[k]). I wonder if there is any method to sum up efficiently. If that is slow the culprit is probably the d2() function. If so results = [0] * 4 for k in xrange(1000): for i, v in enumerate(d2(t[k])): results[i] += v won't help. Can you tell us what's inside d2()? Thanks for reply, Christian and Peter. Actually, the d2() is the Hessian function of a simple function (derived by using ad package, http://pythonhosted.org//ad/). The package hasn't supported Numpy array so far. And I am still not how to take a look inside d2(). Because I have to use d2() in a heavy way for iterative algorithm, the efficiency is a issue in my case. Following is an example. import scipy from scipy import stats import numpy from ad import adnumber from ad.admath import * from ad import jacobian from ad import gh # the gradient and hessian functions generator from ad import * import time people = 1000 range_people = xrange(people) dim0 = 2; mean0 = [0,0]; cov0 = [[1,0],[0,1]] seed([1]) t = stats.multivariate_normal.rvs(mean0,cov0,people) t = t.reshape(people,dim0) t = t.tolist() # back to list x = [0, 0, 1, 2] point = 2 def p(x,t,point,z,obs): d = x[0] tau = [0]+[x[1:point]] a = x[point:len(x)] at = sum(i*j for i, j in zip(a, t)) nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)] de = sum(nu, axis=0) probability = [nu[k]/de for k in xrange(point)] return probability[obs] d1, d2 = gh(p) tStart = time.time() z = range(point) re = [d2(x,t[k],2,z,1) for k in range_people] tEnd = time.time() print It cost %f sec % (tEnd - tStart) -- https://mail.python.org/mailman/listinfo/python-list
Re: list comprehension return a list and sum over in loop
Jussi Piitulainen於 2014年12月12日星期五UTC+8下午7時12分39秒寫道: KK Sasa writes: def p(x,t,point,z,obs): d = x[0] tau = [0]+[x[1:point]] a = x[point:len(x)] at = sum(i*j for i, j in zip(a, t)) nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)] de = sum(nu, axis=0) probability = [nu[k]/de for k in xrange(point)] return probability[obs] I must be blind, but this looks like computing a whole probability distribution and then throwing almost all of it away. Can't this just return nu[obs]/de? The expression for tau also seems weird to me. Isn't it equivalent to [0, x[1:point]], a two-element list with the second element a list? How can sum(tau[k]) work at all then, for any k 1? This is just a probability of binary response. Not continuous one. Tau is a parameter and just have two in this case. -- https://mail.python.org/mailman/listinfo/python-list
Re: list comprehension return a list and sum over in loop
Peter Otten於 2014年12月12日星期五UTC+8下午8時32分55秒寫道: Jussi Piitulainen wrote: KK Sasa writes: def p(x,t,point,z,obs): d = x[0] tau = [0]+[x[1:point]] a = x[point:len(x)] at = sum(i*j for i, j in zip(a, t)) nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)] de = sum(nu, axis=0) probability = [nu[k]/de for k in xrange(point)] return probability[obs] I must be blind, but this looks like computing a whole probability distribution and then throwing almost all of it away. Can't this just return nu[obs]/de? The expression for tau also seems weird to me. Isn't it equivalent to [0, x[1:point]], a two-element list with the second element a list? How can sum(tau[k]) work at all then, for any k 1? Also, after adding from numpy.random import seed to the code I run into the next problem: Traceback (most recent call last): File hessian.py, line 34, in module re = [d2(x,t[k],2,z,1) for k in range_people] File /home/petto/.local/lib/python2.7/site-packages/ad/__init__.py, line 1114, in hess return func(xa, *args).hessian([xa]) File hessian.py, line 26, in p nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)] TypeError: 'int' object is not iterable OP: Optimizations only make sense when you can start from a known-good base. You should sort out the logic of your problem (we probably can't help you with that), then fix the bugs in your code and only then revisit the speed issue. I have no idea why you added from numpy.random import seed to this syntax. Even I added that, my python didn't complain any bugs inside. Maybe your ad package was not be installed correctly? -- https://mail.python.org/mailman/listinfo/python-list
Re: list comprehension return a list and sum over in loop
Sorry, i should say I'm using pythonxy, maybe it imports other things. -- https://mail.python.org/mailman/listinfo/python-list
[issue41868] SMTPLIB integrate or provide option to use "logging"
New submission from KK Hiraskar : Currently "smtplib" is directly printing data to stdout/stderr, and not getting any good way to get this data in to the logs written by "logging" please provide an option to achieve this. -- components: email messages: 377537 nosy: barry, hpkkumar007, r.david.murray priority: normal severity: normal status: open title: SMTPLIB integrate or provide option to use "logging" type: enhancement ___ Python tracker <https://bugs.python.org/issue41868> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Python code: brief
List , I have come across a difficulty to understand the code in this file. I am unable to understand exactly what the code snippet is doing here. https://raw.githubusercontent.com/CODARcode/MDTrAnal/master/lib/codar/oas/MDTrSampler.py I am new to this type of scientific computing code snippets and it is coded by someone. Due to a requirement I would like to understand what these lines of code will do exactly. If someone could explain to me what the code snippets do in the code blocks, it will be a great help . Thanks in advance Krish -- https://mail.python.org/mailman/listinfo/python-list
NEO6 GPS with Py PICO with micropython
List , I am following this tutorial to get latitude and longitude data using NEO6 GPS module and Py PICO to read the GPS data from the device. I followed the code specified in this tutorial. https://microcontrollerslab.com/neo-6m-gps-module-raspberry-pi-pico-micropython/ I have installed thony IDE in my Desktop(windows PC) and run the code after the devices all connected and using USB cable connected to my PC. When I ran the program I am able to see the output of latitude and longitude in the console of thony IDE. But between certain intervals of a few seconds I am getting the latitude and longitude data ( its printing GPS data not found ?? ) in the python console. The satellite count from the $GGPA output showing 03 .. and the GPS data not found repeating randomly for intervals of seconds. Any hints why it is missing the GPS data (randomly) ?? PS:- The GPS device I placed outside my window and connected to the PC with a USB cable from the PICO module. GPS device NEO6 light (Red LED ) blinking even though the " GPS data not found" messages in th python console. Any hints ?? most welcome Yours, Krishane -- https://mail.python.org/mailman/listinfo/python-list
Re: NEO6 GPS with Py PICO with micropython
List, Just commented the // gpsModule.readline() in the while loop, ( refer the link https://microcontrollerslab.com/neo-6m-gps-module-raspberry-pi-pico-micropython/ ) while True: # gpsModule.readline() // This line commented out and the "GPS not found message disappeared". buff = str(gpsModule.readline()) parts = buff.split(',') The GPS not found error which appears intermittently in the output python console for few seconds ( say 7 to 8 seconds its printing the lines " GPS data not found" ) now disappears. Any thoughts? How the above line comment made it vanish the "GPS data not found" error output. Krishane On Wed, Nov 30, 2022 at 3:58 AM rbowman wrote: > On Tue, 29 Nov 2022 17:23:31 +0530, KK CHN wrote: > > > > When I ran the program I am able to see the output of latitude and > > longitude in the console of thony IDE. But between certain intervals > > of a few seconds I am getting the latitude and longitude data ( its > > printing GPS data not found ?? ) in the python console. > > I would guess the 8 seconds in > > timeout = time.time() + 8 > > is too short. Most GPS receivers repeat a sequence on NMEA sentences and > the code is specifically looking for $GPGGA. Add > > print(buff) > > to see the sentences being received. I use the $GPRMC since I'm interested > in the position, speed, and heading. It's a different format but if you > only want lat/lon you could decode it in a similar fashion as the $GPGGA. > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list