File processing
Hello, I'm Gopal. I'm looking for a solution to the following problem: I need to create a text file config.txt having some parameters. I'm thinking of going with this format by having "Param Name - value". Note that the value is a string/number; something like this: PROJECT_ID = "E4208506" SW_VERSION = "18d" HW_VERSION = "2" In my script, I need to parse this config file and extract the Values of the parameters. I'm very new to python as you can understand from the problem. However, I've some project dealines. So I need your help in arriving at a simple and ready-made solution. Regards, Gopal. -- http://mail.python.org/mailman/listinfo/python-list
Re: File processing
Thanks for the reference. However, I'm not understanding how to use it. Could you please provide with an example? Like I open the file, read line and give it to parser? Please help me. -- http://mail.python.org/mailman/listinfo/python-list
Re: File processing
Thank you very much. That works!!! -- http://mail.python.org/mailman/listinfo/python-list
Changing the module not taking effect in calling module
Hi, I've a module report.py having a set of funtions to open/close/write data to a log file. I invoke these functions from another module script.py. Whenever I'm changing something in report.py, I'm running the file (however, it has not effect). After that I'm running script.py again. However, the output is not taking effect. If I shut the IDLE interpreter and all the other files and then reopen again; and then run script.py, the output is taking effect. Is there any way to improve it? I'm new to Python. -Gopal. -- http://mail.python.org/mailman/listinfo/python-list
problem in implementing multiprocessing
Hello, I am trying to implement the multiprocessing in my application to take advantage of multiple cores. I have created two Separate process something like this. que = Queue Process(target = getData, args=(que , section, MdbFile,)).start() Process(target = getData, args=(que , section, MdbFile,)).start() In getData function I create the object(max 7MB size) and add in to queue (que.put (object)). After that I fetch the object using que.get () and use in my application. but it takes more time to get the data. Any one can help me out this problem. Thanks, Sibtey My code< from multiprocessing import Process, Queue def getData(queue, section, mdbFile): """ This function returns the gapappdata for the given mdb file. """ app = MdbFile(mdbFile) mdbData = app.data#it is a heavy object queue.put((section,mdbData)) def getData2(mdbFile): """ This function returns the gapappdata for the given mdb file. """ app = MdbFile(mdbFile) mdbData = app.data#it is a heavy object return mdbData def test_multipleProcess(fromMdbFile, toMdbFile): #multipleProcess t1 = time.time() queue = Queue() sections = ['From', 'To'] Process(target= getData_1, args=(queue, 'From',fromMdbFile,)).start() Process(target= getData_1, args=(queue, 'To',toMdbFile,)).start() section, gapAppData = queue.get() section, gapAppData = queue.get() t2 = time.time() print "total time using multiProcessing:",t2-t1 d1 = getData2(fromMdbFile) d2 = getData2(toMdbFile) print "total time withought multiProcessing:", time.time()-t2 if __name__=='__main__': f1 =r" a.mdb" f2 =r"b.mdb" test_multipleProcess(f1,f2) -- http://mail.python.org/mailman/listinfo/python-list
RE: problem in implementing multiprocessing
I create two heavy objects sequentially without using multipleProcessing then creation of the objects takes 2.5 sec.if i create these two objects in separate process then total time is 6.4 sec. i am thinking it is happening due to the pickling and unpickling of the objects.if i am right then what could be the sollution. my system configuration: dual-core processor winXP python2.6.1 gopal mishra wrote: > Hello, > > I am trying to implement the multiprocessing in my application to take > advantage of multiple cores. I have created two > > Separate process something like this. > > que = Queue > Process(target = getData, args=(que , section, MdbFile,)).start() > Process(target = getData, args=(que , section, MdbFile,)).start() > > In getData function I create the object(max 7MB size) and add in to queue > (que.put (object)). > > After that I fetch the object using que.get () and use in my application. > but it takes more time to get the data. More time than what? Than not getting the date? Than getting it some other way? CPU, OS, and Python version may also be relevant. > Any one can help me out this problem. > > Thanks, > Sibtey > > My code<<<<< > from multiprocessing import Process, Queue > > def getData(queue, section, mdbFile): > """ > This function returns the gapappdata for the given mdb file. > """ > app = MdbFile(mdbFile) > mdbData = app.data#it is a heavy object > queue.put((section,mdbData)) > > def getData2(mdbFile): > """ > This function returns the gapappdata for the given mdb file. > """ > app = MdbFile(mdbFile) > mdbData = app.data#it is a heavy object > return mdbData > > def test_multipleProcess(fromMdbFile, toMdbFile): > #multipleProcess > t1 = time.time() > queue = Queue() > sections = ['From', 'To'] > Process(target= getData_1, args=(queue, 'From',fromMdbFile,)).start() > Process(target= getData_1, args=(queue, 'To',toMdbFile,)).start() > section, gapAppData = queue.get() > section, gapAppData = queue.get() > t2 = time.time() > print "total time using multiProcessing:",t2-t1 > d1 = getData2(fromMdbFile) > d2 = getData2(toMdbFile) > print "total time withought multiProcessing:", time.time()-t2 > > > > > > if __name__=='__main__': > f1 =r" a.mdb" > f2 =r"b.mdb" > test_multipleProcess(f1,f2) > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
RE: problem in implementing multiprocessing
i know this is not an io - bound problem, i am creating heavy objects in the process and add these objects in to queue and get that object in my main program using queue. you can test the this sample code import time from multiprocessing import Process, Queue class Data(object): def __init__(self): self.y = range(1, 100) def getdata(queue): data = Data() queue.put(data) if __name__=='__main__': t1 = time.time() d1 = Data() d2 = Data() t2 = time.time() print "without multiProcessing total time:", t2-t1 #multiProcessing queue = Queue() Process(target= getdata, args=(queue, )).start() Process(target= getdata, args=(queue, )).start() s1 = queue.get() s2 = queue.get() t2 = time.time() print "multiProcessing total time::", t2-t1 -Original Message- From: James Mills [mailto:prolo...@shortcircuit.net.au] Sent: Saturday, January 17, 2009 10:37 AM To: gopal mishra Cc: python-list@python.org Subject: Re: problem in implementing multiprocessing On Fri, Jan 16, 2009 at 7:16 PM, gopal mishra wrote: > I create two heavy objects sequentially without using multipleProcessing > then creation of the objects takes 2.5 sec.if i create these two objects in > separate process then total time is 6.4 sec. > > i am thinking it is happening due to the pickling and unpickling of the > objects.if i am right then what could be the sollution. > > my system configuration: > dual-core processor > winXP > python2.6.1 System specs in this case are irrelevant. What you are experiencing is most likely an I/O bound problem - using multiprocessing may likely not help you solve the problem any faster because of your I/O constraint. cheers James -- http://mail.python.org/mailman/listinfo/python-list
How to get text from a surface
Hi, I am loading an image into pygame. i am trying to get the text from the surface. I used pyTesser to read the text from a surface/image but if the font size of the text is less then 16, it doesn't give me back the correct text from the surface. Is there any other way to get the text from the pygame surface. Thanks, Gopal -- http://mail.python.org/mailman/listinfo/python-list
Install NumPy in python 2.6
Hi, I am trying to install SciPy and NumPy in Python 2.6 (OS - Win XP). http://downloads.sourceforge.net/numpy/numpy-1.2.1.tar.gz http://downloads.sourceforge.net/scipy/scipy-0.7.0.tar.gz While installing numpy It gives following installation error. Running from numpy source directory. non-existing path in 'numpy\\distutils': 'site.cfg' c:\temp\easy_install-wgr5j_\numpy-1.2.1\numpy\distutils\system_info.py:1340: Use rWarning: Atlas (http://math-atlas.sourceforge.net/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [atlas]) or by setting the ATLAS environment variable. warnings.warn(AtlasNotFoundError.__doc__) c:\temp\easy_install-wgr5j_\numpy-1.2.1\numpy\distutils\system_info.py:1349: Use rWarning: Blas (http://www.netlib.org/blas/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [blas]) or by setting the BLAS environment variable. warnings.warn(BlasNotFoundError.__doc__) c:\temp\easy_install-wgr5j_\numpy-1.2.1\numpy\distutils\system_info.py:1352: Use rWarning: Blas (http://www.netlib.org/blas/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [blas_src]) or by setting the BLAS_SRC environment variable. warnings.warn(BlasSrcNotFoundError.__doc__) c:\temp\easy_install-wgr5j_\numpy-1.2.1\numpy\distutils\system_info.py:1247: Use rWarning: Atlas (http://math-atlas.sourceforge.net/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [atlas]) or by setting the ATLAS environment variable. warnings.warn(AtlasNotFoundError.__doc__) c:\temp\easy_install-wgr5j_\numpy-1.2.1\numpy\distutils\system_info.py:1258: Use rWarning: Lapack (http://www.netlib.org/lapack/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [lapack]) or by setting the LAPACK environment variable. warnings.warn(LapackNotFoundError.__doc__) c:\temp\easy_install-wgr5j_\numpy-1.2.1\numpy\distutils\system_info.py:1261: Use rWarning: Lapack (http://www.netlib.org/lapack/) sources not found. Directories to search for the sources can be specified in the numpy/distutils/site.cfg file (section [lapack_src]) or by setting the LAPACK_SRC environment variable. warnings.warn(LapackSrcNotFoundError.__doc__) error: Setup script exited with error: None How I can install numpy? Thanks, Gopal -- http://mail.python.org/mailman/listinfo/python-list
OMPC- m-script to python script convertor
Hi, I am trying to convert Matlab script to python script using OMPC.( http://ompc.juricap.com/ ) My matlab code is (.m file) Npts=100; R=0.5; X=[0:1/Npts:1]'; Y=[0:0.01:1]'; for i=1:Npts+1 if(X(i) <= .5) Ytop(i)=1.0; Ybot(i)=0.0; else Z=sqrt(R^2-(X(i)-R)^2)-R; Ytop(i)=2*R+Z; Ybot(i)=-Z; end end OMPC convert it to (.pym) file from ompc import * Npts = 100 R = 0.5 X = mcat([mslice[0:1 / Npts:1]]).cT Y = mcat([mslice[0:0.01:1]]).cT for i in mslice[1:Npts + 1]: if (X(i) <= .5): Ytop(i).lvalue = 1.0 Ybot(i).lvalue = 0.0 else: Z = sqrt(R ** 2 - (X(i) - R) ** 2) - R Ytop(i).lvalue = 2 * R + Z Ybot(i).lvalue = -Z end end while executing pym file it gives memory error at line no 5 i.e.(X = mcat([mslice[0:1 / Npts:1]]).cT) I also tryied out in IDE, it gives error on, >>> mslice[0:1 / Npts:1] Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\site-packages\ompc\ompclib\ompclib_numpy.py", line 1056, in __getitem__ s.init_data() File "C:\Python25\lib\site-packages\ompc\ompclib\ompclib_numpy.py", line 910, in init_data self._a = np.array(list(self), dtype='f8').reshape(self.msize[::-1]) MemoryError Is there any updated OMPC version, which has solved this issue. How this can be solved. Thanks, Gopal -- http://mail.python.org/mailman/listinfo/python-list
How save clipboard data as bmp file
Hi, I am trying to save my clipboard data (format is CF_ENHMETAFILE) as BitMap file (.BMP). Can any on suggest how to do this. Thanks & Regards, Gopal -- http://mail.python.org/mailman/listinfo/python-list
How to save clipboard data as bmp file
I have used ImageGrab.grabclipboard() to get the clipboard image data, it returns None. This function only supports if the clipboard data format is CF_BITMAP. Is there any way to save clipboard data format CF_ENHMETAFILE to bitmap file using win32 programming. -- Gopal > I am trying to save my clipboard data (format is CF_ENHMETAFILE) as BitMap > file (.BMP). Have a look at PIL's ImageGrab module: http://www.pythonware.com/library/pil/handbook/imagegrab.htm I'm not sure if the current version supports metafiles, but it's easy enough to try. TJG -- http://mail.python.org/mailman/listinfo/python-list
How to set directory in save as combo box
Hi, In 'save as' dialog of window application, I am trying to set the path in 'save in' combo box using python win32 programming. How we can set the directory in the 'save in' combo box. Thanks, Gopal -- http://mail.python.org/mailman/listinfo/python-list
How to set directory in save as combo box
TJG, I am trying to save a file, it is working fine. But if the file is not on the foreground while setting combo box directory, changing the value in the combo box by setLookIn() appear on the foreground window. I am using following functionality to save the file. def saveAsFile(fileName, path): while 1: # findWindow function returns a window class which contains all its childwindow and its components with handler id. saveaswindow = self.findWindow('Save As') saveaswindow._setLookIn(path) #save function save the file in specified path saveaswindow.save(False) def _setLookIn(self, path): try: #XXX set the directory in combo box win32gui.SendMessage(win32con.CB_DIR, 0, path) win32gui.SendMessage(win32con.WM_LBUTTONDOWN, 0, 0) win32gui.SendMessage(win32con.WM_LBUTTONUP, 0, 0) win32gui.SendMessage(win32con.WM_LBUTTONDOWN, 0, 0) win32gui.SendMessage(win32con.WM_LBUTTONUP, 0, 0) except : raise OpenSaveDialogError('Cannot set Look In path. %s is not a valid folder path.' % path) -Original Message- From: Tim Golden [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2008 1:22 PM Cc: python-list@python.org Subject: Re: How to set directory in save as combo box gopal mishra wrote: > In 'save as' dialog of window application, I am trying to set the path in > 'save in' combo box using python win32 programming. > How we can set the directory in the 'save in' combo box. There are several ways to display a "Save As" dialog. Can you post [a minimal version of] the code you're using so we can see what you're doing, please? TJG -- http://mail.python.org/mailman/listinfo/python-list
cPickle
I have 3 objects and want to save in one pickle file. I used cPickle to dump 3 objects in a pkl file i.e cPickle.dump(object1, fileobject, -1) cPickle.dump(object2, fileobject, -1) cPickle.dump(object3, fileobject, -1) I have changed the 3rd object and want to save the updated 3rd object in the pickle file. I have to dump all the 3 objects again. Is there any way to dump only the 3rd object in to the pkl file. -- http://mail.python.org/mailman/listinfo/python-list
how to create nested classes dynamically
I have class structure as below. How can I create the following nested class and its properties dynamically. class AA(object): class BB(object): def setBB1(self, value): ##some code def getBB1(self): bb1 = #somecode return bb1 bb1 = property(getBB1, setBB1, None, None) bb2 = ... bb = BB() class CC(object): cc = CC() aa = AA() print aa.bb.bb1 aa.bb.bb2 = '10' print aa.bb.bb2 I want to achive dot structure get or set value.i.e. aa.bb.bb1 Thanks, Gopal -- http://mail.python.org/mailman/listinfo/python-list
Fwd: Installation Errors
Hi Python Support Team, I have subscribed now and re-sending my query. Please suggest. I have an Issue installing python 3.7 on my work computer. It says core.msi package not found during installation. Can you please help me with steps to resolve this issue? Thank you, Venu -- https://mail.python.org/mailman/listinfo/python-list
How to reduce the memory size of python
Hi, When i write following pyhon program and execute it in linux machine, if __name__=='__main__': while True: pass When i check the VmRSS size, it shows 2956 KB in size. Is there any way to reduce the memory size taken by python. I am working in flash memory devices. Any suggession is highly helpfull to me. Thanks, Gopal -- http://mail.python.org/mailman/listinfo/python-list
RE: How to reduce the memory size of python
Hi, I use twisted framework too to handle the xmlrpc request. It takes around 3-4MB of memory while importing itself. Is there any python coding standard I should follow to save the memory. Like import logging takes 1MB of memory. We only use on function getLogger by 'from logging import getLogger' But it still take the same 1 MB memory. Instead of loading whole logging module only load the getLogger function. I there any way to save the memory with taking care of small things in code.. Thanks, Gopal -Original Message- From: python-list-bounces+qbx634=motorola@python.org [mailto:python-list-bounces+qbx634=motorola@python.org] On Behalf Of Steve Holden Sent: Thursday, January 07, 2010 1:20 PM To: python-list@python.org Subject: Re: How to reduce the memory size of python Mishra Gopal-QBX634 wrote: > Hi, > > When i write following pyhon program and execute it in linux machine, > > if __name__=='__main__': > while True: > pass > > When i check the VmRSS size, it shows 2956 KB in size. > > Is there any way to reduce the memory size taken by python. > > I am working in flash memory devices. > > Any suggession is highly helpfull to me. > It would not be easy to reduce the size of the standard interpreter, but there are various implementations for embedded devices. You may get some help from http://wiki.python.org/moin/Tiny%20Python and http://wiki.python.org/moin/Tiny%20Python A company called Synapse has a working cut-down Python implementation that they embed in their 802.15 wireless mesh devices, which IIRC occupies less than 128K. There is a lot in the standard interpreter that you won't need - many embedded systems don't need floating point arithmetic, for example. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS:http://holdenweb.eventbrite.com/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
How to forward request through lighttpd server to xmlrpc server
Hi, I have Lighttpd web server running on port 80. and i have a xmlrpc web server running on port 8085 How i can send all my request/response to xmlrpc server through lighttpd server running on port 80? Thanks and regards, Gopal -- http://mail.python.org/mailman/listinfo/python-list