Can't catch CTRL-C when SimpleXMLRPCServer running ?

2013-02-20 Thread shearichard
Hi - I have a script which instantiates a SimpleXMLRPCServer server and which I use to simulate a 'real server' when developing client scripts which will eventually get used with the 'real server'. I would like to stop the script running in response to a CTRL-C. The script is run on windows. T

Re: Object Models - decoupling data access - good examples ?

2012-08-04 Thread shearichard
> > Just out of curiosity, why do you eschew ORMs? > Good question ! I'm not anti-ORM (in fact in many circs I'm quite pro-ORM) but for some time I've been working with a client who doesn't want ORMs used (they do have quite good reasons for this although probably not as good as they think).

Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-04 Thread shearichard
One reason you may be having difficulty is that unlike some languages (C++/Java) object-orientation is not a be all and end all in Python, in fact you could work with Python for a long time without really 'doing it' at all (well other than calling methods/properties on existing API's). Having sa

Object Models - decoupling data access - good examples ?

2012-08-04 Thread shearichard
I'm interested in best practice approaches to : decoupling data access code from application code; and translations between database structures and domain objects. For some time I've done database access by in a particular way and while I think it's OK it's not very pythonic so I'd be intereste

Re: "constant sharing" works differently in REPL than in script ?

2012-06-19 Thread shearichard
Thanks for all the replies. I hadn't thought about the opportunities that exist for optimization when the whole script is there (or when compound operations are taking place) by contrast with plain old REPL ops. I liked your code Chris demoing the different ranges in different versions. I tried

"constant sharing" works differently in REPL than in script ?

2012-06-18 Thread shearichard
Listening to 'Radio Free Python' episode 8 (http://radiofreepython.com/episodes/8/ - around about the 30 minute mark) I heard that Python pre creates some integer constants to avoid a proliferation of objects with the same value. I was interested in this and so I decided to try it out. First I

Re: Serialize my class as JSON causes "__init__() got an unexpected keyword argument 'indent'" ?

2010-12-18 Thread shearichard
On Dec 18, 11:30 pm, Peter Otten <__pete...@web.de> wrote: > shearichard wrote: > > Hi - I've got a straightforward class I want to serialize as JSON > > (actually I want to a serialize a list of them but I believe that's > > irrelevant). > > >

Serialize my class as JSON causes "__init__() got an unexpected keyword argument 'indent'" ?

2010-12-18 Thread shearichard
Hi - I've got a straightforward class I want to serialize as JSON (actually I want to a serialize a list of them but I believe that's irrelevant). I've subclassed JSONEncoder and defined my own version of the 'default' method ( based upon what I read at http://docs.python.org/library/json.html )

Re: Newbie question about importing modules.

2010-12-17 Thread shearichard
On Dec 17, 4:42 pm, cronoklee wrote: > Hi > I'm starting my first python project but I'm having trouble getting > off the ground. > I've read all I can find about relative and absolute import paths but > it's just not making sense to me... There seems to be around ten > different ways to import a

pudb on windows (dependent upon unix only termios ?)

2010-12-16 Thread shearichard
Hi - I was just trying to install the Python debugger pudb (http:// pypi.python.org/pypi/pudb) and easy install fell over saying it couldn't find a module termios. It turns out termios is only for Unix (http://docs.python.org/library/ termios.html). Does anyone know of way around this ? Is there

Re: find memory leaks in running program

2010-12-07 Thread shearichard
On Dec 8, 5:51 am, Marco Hornung wrote: > Hey, > > -- > questions > -- > 1. What are the best tools to analyze pythons mem

Re: PEP8 compliance and exception messages ?

2010-12-07 Thread shearichard
On Dec 7, 9:17 am, Andreas Waldenburger wrote: > On Mon, 6 Dec 2010 00:22:49 -0500 Andreas Waldenburger > wrote: > > > > > On Sun, 5 Dec 2010 19:52:54 -0800 Chris Rebert > > wrote: > > > > On Sun, Dec 5, 2010 at 7:40 PM, shearichard > > > wrote

Re: PEP8 compliance and exception messages ?

2010-12-07 Thread shearichard
On Dec 6, 6:21 pm, Ben Finney wrote: > shearichard writes: > > Hi - PEP8 says lines should not exceed 79 characters in length > > (http://www.python.org/dev/peps/pep-0008/). > > > So if you've got some code that looks like this : > > > raise fooMod.fooExcep

PEP8 compliance and exception messages ?

2010-12-05 Thread shearichard
Hi - PEP8 says lines should not exceed 79 characters in length ( http://www.python.org/dev/peps/pep-0008/ ). So if you've got some code that looks like this : raise fooMod.fooException("Some message which is quite long") ... and assuming a certain amount of indenting you're going to break that g

Re: Pypi (Cheeseshop) Score - derivation of ?

2010-11-24 Thread shearichard
On Nov 25, 3:54 pm, Ben Finney wrote: > shearichard writes: > > Hi - Anyone know how the score offered by Pypi is derived ? > > Specifically, the score offered in response to a search query. > > > For instance in ... > > >http://pypi.python.org/pypi?%3Aacti

Pypi (Cheeseshop) Score - derivation of ?

2010-11-24 Thread shearichard
Hi - Anyone know how the score offered by Pypi is derived ? For instance in ... http://pypi.python.org/pypi?%3Aaction=search&term=spam&submit=search ... 'bud.nospam 1.0.1' has a score of 9 but 'pydspam 1.1.9' has a score of 7. Where are those numbers from and what do they mean ? Thanks R.

PIL - "despeckle" image ?

2006-11-16 Thread shearichard
Hi - I have some images which I would like to remove specks from using the PIL. I would like to be able to say that if a pixel is in a blob of less than n contiguous pixels then all pixels in that blob should be removed. The images are 8 bit images with only 0 and 255 values. I can think of quite

MySQLdb - parameterised SQL - how to see resulting SQL ?

2006-05-17 Thread shearichard
Hi - I've got SQL that looks like this ... cursor = self.MySQLDb_conn.cursor(cursorclass=MySQLdb.cursors.DictCursor) sqlQuery = "SELECT * FROM T1 WHERE C1 = %s and C2 = %s" sql = cursor.execute(sqlQuery,(strURLAlias,strSessionID)) rows = cursor.fetchall() cursor.close ... i would be interested in

Re: MySQLdb "begin()" -

2006-04-25 Thread shearichard
Thanks for your advice. In fact subsquent to posting I started using ... conn.autocommit = False ... as a synonm for ... conn.begin() ... and as you say that does the job. (Sorry i should have said it's not practicable to turn off autocommit always [or rather it may be but I'm not about to shak

Re: MySQLdb "begin()" -

2006-04-25 Thread shearichard
"What do i expect the begin method to do" ? Explicitly start a transaction (and therefore suppress autocommits) in an environment where autocommit is on. No i haven't read the pep, thanks for that. -- http://mail.python.org/mailman/listinfo/python-list

MySQLdb "begin()" -

2006-04-25 Thread shearichard
Hi - Feeling a bit weird about this but I cannot find the 'begin' method on a connection object of MySQLdb. Can anyone explain why ? I'm using version 1.2.0 which is pretty recent and I've read that 'begin' should be a method of connection but it's not there ! Feeling pretty puzzled ! Below are t

Convert (sorted) list of dics to nested list ?

2006-03-21 Thread shearichard
Hi - I want to take something like ... lstIn = [] lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 10, 'LEA_AUTOID': 1000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2000}) lstIn.append({'COM_AUTOID': 1, 'PRG_AUTOID': 11, 'LEA_AUTOID': 2001}) lstIn.append({'COM_AUTOID': 1, 'PRG_AU

Re: How to Mount/Unmount Drives on Windows?

2006-02-25 Thread shearichard
This looks like it might help you ... http://support.microsoft.com/?kbid=311272 ... although the blurb does say "DevCon is not redistributable. It is provided for use as a debugging and development tool". There is an article about it at ... http://tinyurl.com/4kb8m regards richard. -- http

Re: MySQLDB - parameterised SQL - "TypeError: not all arguments converted during string formatting"

2006-02-19 Thread shearichard
Hi Dennis - Thanks for your help with this Dennis Lee Bieber wrote: > On 19 Feb 2006 16:26:15 -0800, [EMAIL PROTECTED] declaimed the > following in comp.lang.python: > > > Hi - I have written some python to insert a row into a table using > > MySQLDB. I have never before written SQL/Python us

MySQLDB - parameterised SQL - "TypeError: not all arguments converted during string formatting"

2006-02-19 Thread shearichard
Hi - I have written some python to insert a row into a table using MySQLDB. I have never before written SQL/Python using embedded parameters in the SQL and I'm having some difficulties. Could someone point me in the right direction please ? The python looks like this : import MySQLdb import MySQL