Is it more CPU-efficient to read/write config file or read/write sqlite database?

2013-12-14 Thread JL
I have a number of python processes which communicate with each other through writing/reading config text files. The python ConfigParser is used. I am wondering if it is more CPU-efficient to switch to using sqlite database instead of using configuration files. If the software does plenty of re

Is it possible to mix python with php?

2013-12-13 Thread JL
Python is my favorite language. Very often, I am forced to use other languages like php because of better library support for web applications. Is it possible to write functions in python and then get php to call these functions? Thank you -- https://mail.python.org/mailman/listinfo/python-list

Is there any advantage to using a main() in python scripts?

2013-12-11 Thread JL
Python scripts can run without a main(). What is the advantage to using a main()? Is it necessary to use a main() when the script uses command line arguments? (See script below) #!/usr/bin/python import sys def main(): # print command line arguments for arg in sys.argv[1:]: pri

Re: How to catch error messages in ftplib?

2013-11-19 Thread JL
the file except Exception, errObj: print Exception print errObj file.close() # close file and FTP session.quit() On Tuesday, November 19, 2013 6:18:07 PM UTC+8, JL wrote: > I have the following code; > > > > try: > > session

How to catch error messages in ftplib?

2013-11-19 Thread JL
I have the following code; try: session = FTP(ftp_server_ip,ftp_user,ftp_password) file = open(filename,'rb') # file to send session.storbinary('STOR ' + filename, file) # send the file except Exception, errObj: print Exception print errObj

Re: Implementing #define macros similar to C on python

2013-11-15 Thread JL
On Saturday, November 16, 2013 8:22:25 AM UTC+8, Mark Lawrence wrote: > Yes but please don't top post. Actually print is a statement in Python > 2 so your code should work if you use > from __future__ import print_function > at the top of your code. > Would you also be kind enough to read and ac

Re: Implementing #define macros similar to C on python

2013-11-15 Thread JL
15, 2013 at 1:29 PM, JL wrote: > > > One of my favorite tools in C/C++ language is the preprocessor macros. > > > > > > One example is switching certain print messages for debugging use only > > > > > > #ifdef DEBUG_ENABLE > > > DEBUG_PRINT

Implementing #define macros similar to C on python

2013-11-14 Thread JL
One of my favorite tools in C/C++ language is the preprocessor macros. One example is switching certain print messages for debugging use only #ifdef DEBUG_ENABLE DEBUG_PRINT print #else DEBUG_PRINT Is it possible to implement something similar in python? Thank you. -- https://mail.python.org/

Re: Implementing a multivibrator function with python

2013-11-12 Thread JL
I am actually running python on raspberry pi. The trigger event is a button-press. On Monday, November 11, 2013 6:56:03 PM UTC+8, Dave Angel wrote: > On Mon, 11 Nov 2013 01:41:58 -0800 (PST), JL > > wrote: > > > - If the event happens again before the 5secs expire, the h

Implementing a multivibrator function with python

2013-11-11 Thread JL
I am trying to implement a multivibrator function with python. This is how it works; - An trigger event happens - Upon receiving the event, a variable goes high for 5secs, then go low. - If the event happens again before the 5secs expire, the high duration will be extended by another 5 secs. Th

Multiple scripts versus single multi-threaded script

2013-10-03 Thread JL
What is the difference between running multiple python scripts and a single multi-threaded script? May I know what are the pros and cons of each approach? Right now, my preference is to run multiple separate python scripts because it is simpler. -- https://mail.python.org/mailman/listinfo/pytho

Re: PyGame, window is not closing, tut not helping

2008-05-12 Thread JL
If the game runs normally without IDLE, then, to run it from IDLE, add pygame.quit() at the end of the script: if __name__ == "__main__": MainWindow = PyManMain() MainWindow.MainLoop() pygame.quit() ... and just before the sys.exit(): def MainLoop(self): """This is the Ma

Re: pickle and __slots__

2007-10-04 Thread JL
I added the following method to the 2 subclasses of asyncore.dispatcher and asynchat.async_chat and now pickle works: def __getstate__(self): return Later I will probably modify this method so it returns something more interesting. Thanks for your help! I was confused because I am not

Re: pickle and __slots__

2007-10-04 Thread JL
> Is this a subclass? Look at the parent classes. Its class is a subclass of a similar class, but it indirectly references instances of subclasses of asyncore.dispatcher or asynchat.async_chat. I don't think there are other particular classes. If I remove the first references, pickle works. A

pickle and __slots__

2007-10-04 Thread JL
Hello, I am trying to pickle an object, and I get: TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled I didn't find __slots__ in the object or the class. Is there a way to find it, or to to know which object or class causes the problem? Thanks -- http://