Creating methods depending on packages that have been installed

2005-05-24 Thread C Gillespie
Dear All, What is the best way of creating methods depending on the packages that have been installed. A silly example is try: import somepack class hello: def __init__(self): print 'hi' def some(self): print 'some' except: class hello:

staticmethod and classmethod

2005-05-24 Thread C Gillespie
Hi, Does anyone know of any examples on how (& where) to use staticmethods and classmethods? Thanks Colin -- http://mail.python.org/mailman/listinfo/python-list

Using default a empty dictionary as a default value

2005-03-22 Thread C Gillespie
Dear All, I ran my code through pylint to clean it up and one of the (many) errors it through up was Dangerous default value {} as argument Bascially, I have: class NewClass: def __init__(self, myDict={}): for key, value in myDict: print key, value Obviously, this is not

Re: Calling a method using an argument

2005-02-04 Thread C Gillespie
Dear All, Many thanks Colin "C Gillespie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dear All, > > I have a simple class > class hello: > def world(self): > return 'hello' > def test(self,arg): > retur

Calling a method using an argument

2005-02-03 Thread C Gillespie
Dear All, I have a simple class class hello: def world(self): return 'hello' def test(self,arg): return self.arg When I want to do is: >hello.test('world') 'hello' i.e. pass the method name as an argument. How should I do this? Thanks Colin -- http://mail.python.org/

Re: spawn or fork

2004-12-08 Thread C Gillespie
> What are you trying to do exactly? If you provide more explanations, we may > provide a better help than the simplistic one above. Dear All, Thanks for the suggestions. Basically, I have the situation where a user (via the web) requests data from a database that has to be written to file. Howe

Re: spawn or fork

2004-12-08 Thread C Gillespie
"Miki Tebeka" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello Colin, > > > I have a function > > def printHello(): > > fp = open('file','w') > > fp.write('hello') > > fp.close() > > > > I would like to call that function using spawn or fork. My questions are: > > >

spawn or fork

2004-12-08 Thread C Gillespie
Dear All, I have a function def printHello(): fp = open('file','w') fp.write('hello') fp.close() I would like to call that function using spawn or fork. My questions are: 1. Which should I use 2. How do I call that function if it is defined in the same file. Many thanks Colin --