Re: DBAPI Paramstyle
On Thu, 24 Mar 2005 15:03:13 +0100, Fredrik Lundh <[EMAIL PROTECTED]> \ wrote: > Bob Parnes wrote: > >> I must be missing something, so perhaps someone can explain >> the benefit of a paramstyle over the usual Python formatting >> style and maybe suggest a test to show it. Thanks. > > set the parameter to "0; DROP DATABASE template1;" and see what > happens. > > or set it to os.urandom(1000) and run your test a couple of times to see > what happens. > Thanks for the suggestion. My system does not appear to contain an os.urandom() method. It has a /dev/urandom device, but I don't know how to use it for this purpose, except perhaps to select the first byte that it produces. I have a mediocre talent at programming, which is why I chose python. For me it was a good choice. I note this so that I hope you understand why I say that I don't know what you are driving at. My understanding is that a paramstyle is more efficient than the traditional python approach for repeated use of a query. If so, then I do not see how the choice of a parameter is relevant. If it is more efficient only in a specific abstract case, then one would have to look for other reasons to use it in a practical application. Bob Parnes -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
DBAPI Paramstyle
The following script is a one person's comparison of three methods for accessing a postgresql database using psycopg on a debian computer running python2.3. Following it are the results of running it six times. === from time import time, clock import psycopg MAX_COUNT = 5 def pyMethod(): for n in range(MAX_COUNT): curs.execute('''SELECT %s;''' % n) def formatMethod(): for n in range(MAX_COUNT): curs.execute('''SELECT %s;''', [n]) def pyformatMethod(): for n in range(MAX_COUNT): curs.execute('''SELECT %(n)s;''', {'n':n}) conn = psycopg.connect(host='localhost', database='template1') curs = conn.cursor() for method, func in (('Python method: %f, %f', pyMethod), ('Format method: %f, %f', formatMethod), ('Pyformat method: %f, %f', pyformatMethod)): startTime = time() startClock = clock() func() print method % ((time() - startTime), (clock() - startClock)) === [EMAIL PROTECTED]:~/demo$ ./pyformatTst.py Python method: 9.288770, 3.55000 Format method: 9.457663, 3.82 Pyformat method: 9.446390, 3.70 [EMAIL PROTECTED]:~/demo$ ./pyformatTst.py Python method: 9.152173, 3.40 Format method: 9.314743, 3.76 Pyformat method: 9.329343, 3.84 [EMAIL PROTECTED]:~/demo$ ./pyformatTst.py Python method: 9.262013, 3.49 Format method: 9.344197, 3.57 Pyformat method: 9.402157, 3.50 [EMAIL PROTECTED]:~/demo$ ./pyformatTst.py Python method: 9.170817, 3.86 Format method: 9.509313, 3.26 Pyformat method: 9.380756, 3.77 [EMAIL PROTECTED]:~/demo$ ./pyformatTst.py Python method: 9.271831, 3.54 Format method: 9.375170, 3.65 Pyformat method: 9.426898, 3.78 [EMAIL PROTECTED]:~/demo$ ./pyformatTst.py Python method: 9.192097, 3.72 Format method: 9.244554, 3.69 Pyformat method: 9.368582, 3.76 Similar results occurred with an actual database table. I must be missing something, so perhaps someone can explain the benefit of a paramstyle over the usual Python formatting style and maybe suggest a test to show it. Thanks. Bob Parnes -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: User Identification
On Tue, 08 Feb 2005 12:29:48 -, Bob Parnes <[EMAIL PROTECTED]> wrote: > I have a python program on a server of an all-linux network. It needs to > record the user name running it. Is there a way for the program to extract > the name from the system without a separate log-in dialog? > > Bob Parnes Thanks very much. Had not realized there were so many possibilities. Bob Parnes -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
User Identification
I have a python program on a server of an all-linux network. It needs to record the user name running it. Is there a way for the program to extract the name from the system without a separate log-in dialog? Bob Parnes -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Maximum Number of Class Attributes
On Wed, 26 Jan 2005 10:03:47 +0100, Sylvain Thenault <[EMAIL PROTECTED]> wrote: > On Wed, 26 Jan 2005 02:03:12 +0000, Bob Parnes wrote: > >> In its default configuration, my version of pylint (0.5.0) sets the >> maximum number of class attributes at 7. This seems low to me, but I can >> see how an excessive number might make maintenance more difficult. Is this >> indeed the best value for a maximum under ordinary conditions? If not, can >> anyone suggest a more reasonable value? > > well, this value is very subjective, and may change from one context to > another... For instance at some point I hope that pylint will detect "GUI" > classes and allow more attributes (and methods?) to those. > Anyway that's just an indicator, not a rule of thumb (and pylint itself > has some class with more than 7 attributes...). > > And FYI, this value has been taken from a post to the > testdrivendevelopment at yahoogroups (as most others default values in the > "design analysis" checker). Hum, well... After checking it seems that the > post said 20 attributes. I don't remember why did i get this number down > to 7. If this discussion leads to an agreement for a better number, I > can change the default value. > > -- > Sylvain Thénault LOGILAB, Paris (France). > > http://www.logilab.com http://www.logilab.fr http://www.logilab.org > > Thanks for the information. I *am* using gui classes. -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Maximum Number of Class Attributes
In its default configuration, my version of pylint (0.5.0) sets the maximum number of class attributes at 7. This seems low to me, but I can see how an excessive number might make maintenance more difficult. Is this indeed the best value for a maximum under ordinary conditions? If not, can anyone suggest a more reasonable value? Thanks in advance. Bob Parnes -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt on a Server
On 03 Dec 2004 11:15:26 -0500, Jerry Sievers <[EMAIL PROTECTED]> wrote: > Bob Parnes <[EMAIL PROTECTED]> writes: >> my /etc/ld.so.conf file already has that lib in it. So something else is >> happening, but it clearly has nothing to do with python. > > Have you run ldconfig (probably /sbin/ldconfig) since the line was > added to the /etc ld config file? > Good question. I have not done this often, and the need to run ldconfig after mounting the server /usr directory did not occur to me. So I tried again, running ldconfig, and it still didn't work. After more checking, I found that the entry in /etc/ld.so.conf was "usr/X11R6/lib", instead of "/usr/X11R6/lib". I guess that was good enough during bootup. So adding the slash and running ldconfig again fixed everything. Thanks very much. -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt on a Server
On 29 Nov 2004 11:07:48 -0500, Jerry Sievers <[EMAIL PROTECTED]> wrote: > Bob Parnes <[EMAIL PROTECTED]> writes: > >> I have an application importing qt on a linux server and am missing >> something in trying to run it from a workstation via nfs. The >> workstation has the server /usr directory mounted to its own /usr >> directory, so it can access the necessary files. The error I get is >> >> Traceback (most recent call last): >> File "/demo/revenues.py", line 24, in ? >> from qt import * >> File "/usr/lib/python2.3/site-packages/qt.py", line 24, in ? >> import libsip >> ImportError: libXrender.so.1: cannot open shared object file: >> No such file or directory >> >> I can see the file in /usr/X11R6/lib. So maybe there is a path variable >> that qt.py uses and that has to be set on the workstation. If so, I don't >> know how to find it. Thanks for any help. > > > LD_LIBRARY_PATH=/usr/X11R6/lib > > or if the LD_LIBRARY_PATH exists already, append to it; > > LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/X11R6/lib > > then > > export LD_LIBRARY_PATH Yes, this works. > > Now try running your Python script and see if this helps. If so, read > about ld.config and add that lib to the standard config on the > workstation if you plan on having that NFS mount all the time. > my /etc/ld.so.conf file already has that lib in it. So something else is happening, but it clearly has nothing to do with python. > You might also check to insure that the lib that you are "seeing" is > actually a file and not a symlink to nowhere and that the file has > appropriate perms for a shared lib r-x is typical. > > HTH > The lib is a symlink to another file in the same directory, and the permissions seem to be okay. Thanks very much for your help. > -- > ------- > Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant > 305 321-1144 (mobile http://www.JerrySievers.com/ -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
PyQt on a Server
I have an application importing qt on a linux server and am missing something in trying to run it from a workstation via nfs. The workstation has the server /usr directory mounted to its own /usr directory, so it can access the necessary files. The error I get is Traceback (most recent call last): File "/demo/revenues.py", line 24, in ? from qt import * File "/usr/lib/python2.3/site-packages/qt.py", line 24, in ? import libsip ImportError: libXrender.so.1: cannot open shared object file: No such file or directory I can see the file in /usr/X11R6/lib. So maybe there is a path variable that qt.py uses and that has to be set on the workstation. If so, I don't know how to find it. Thanks for any help. Bob -- Bob Parnes [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list