python shelve on win vs unix

2007-02-09 Thread Tor Erik Soenvisen
Hi, Have a problem using shelve on windows and unix. While my windows box supports dbhash, my unix box supports gdbm, and neither supports what the other does. The problem arises when I try to use the shelve generated in unix on my windows box. Hoepfully there are alternatives to installing th

str and __setitem__

2007-01-25 Thread Tor Erik Soenvisen
Hi, What do I need to do to make the code below work as expected: class str2(str): def __setitem__(self, i, y): assert type(y) is str assert type(i) is int assert i < len(self) self = self[:i] + y + self[1+i:] a = str2('1

Re: len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

2006-11-23 Thread Tor Erik Soenvisen
Steven D'Aprano <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On Thu, 23 Nov 2006 10:48:32 +0000, Tor Erik Soenvisen wrote: > >> Hi, >> >> >> (len(['']) is 1) == (len(['']) == 1) => True > > You shouldn'

len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?

2006-11-23 Thread Tor Erik Soenvisen
Hi, (len(['']) is 1) == (len(['']) == 1) => True Is this the case for all numbers? I've tried running the following: for i in range(1): for j in range(1): if i != j: assert id(i) != id(j), 'i=%d, j=%d, id=%d' % (i, j, id (i)) which execut

Code feedback

2006-11-17 Thread Tor Erik Soenvisen
ester. Here is the server code, HTTPServer.py: # Basic, threaded HTTP server, serving requests via python scripts # Author: Tor Erik Soenvisen # Std lib imports import BaseHTTPServer, os, threading, Queue class HTTPServer(BaseHTTPServer.HTTPServer): """ A threaded HTTP serve

Protecting against SQL injection

2006-10-24 Thread Tor Erik Soenvisen
Hi, How safe is the following code against SQL injection: # Get user privilege digest = sha.new(pw).hexdigest() # Protect against SQL injection by escaping quotes uname = uname.replace("'", "''") sql = 'SELECT privilege FROM staff WHERE ' + \

FTP over SSL

2006-10-20 Thread Tor Erik Soenvisen
Hi, Anyone know about existing code supporting FTP over SSL? I guess pycurl http://pycurl.sourceforge.net/ could be used, but that requires knowledge of libcurl, which I haven't. regards -- http://mail.python.org/mailman/listinfo/python-list

Assigning different Exception message

2006-10-12 Thread Tor Erik Soenvisen
try: self.cursor.execute(sql) except AttributeError, e: if e.message == "oracleDB instance has no attribute 'cursor'": e.message = 'oracleDB.open() must be called before' + \ ' oracleDB.query()' raise At

Oracle database export

2006-10-05 Thread Tor Erik Soenvisen
Hi, I need to export an Oracle database to a DDL-formated file. On the Web, I found a Python script that did exactly this for a MS Access database, but not one for Oracle databases. Does anyone know of such a tool or Python script. regards tores -- http://mail.python.org/mailman/listinfo/pytho