Re: comments? storing a function in an object

2009-07-25 Thread Aahz
In article <20efdb6a-c1a5-47dc-8546-7c4ae548e...@g1g2000pra.googlegroups.com>, Carl Banks wrote: >On Jul 22, 8:38=A0pm, a...@pythoncraft.com (Aahz) wrote: >> In article .com>, >> Carl Banks =A0 wrote: >>> >>>You have to be REALLY REALLY careful not to pass any user-supplied >>>data to it if this

Re: comments? storing a function in an object

2009-07-23 Thread Carl Banks
On Jul 22, 8:38 pm, a...@pythoncraft.com (Aahz) wrote: > In article > , > Carl Banks   wrote: > > >You have to be REALLY REALLY careful not to pass any user-supplied > >data to it if this is a server running on your computer, of course. > > Unless, of course, your users are paying for this service

Re: comments? storing a function in an object

2009-07-22 Thread Aahz
In article , Carl Banks wrote: > >You have to be REALLY REALLY careful not to pass any user-supplied >data to it if this is a server running on your computer, of course. Unless, of course, your users are paying for this service. -- Aahz (a...@pythoncraft.com) <*> http://www.py

Re: comments? storing a function in an object

2009-07-21 Thread Esmail
Thanks *everyone* for your help, and sharing your knowledge. I had no idea that Python functions could have user defined attributes, and I may now not even need the object to wrap my functions in. Amazing what one can learn here .. thanks again! Esmail -- http://mail.python.org/mailman/listinf

Re: comments? storing a function in an object

2009-07-20 Thread Gabriel Genellina
En Mon, 20 Jul 2009 22:53:59 -0300, Esmail escribió: Gabriel Genellina wrote: > If you follow the above suggestions, you'll see that your Function class becomes almost useless: a normal function already IS an object, so you don't have to wrap it inside ANOTHER object unless you need very

Re: comments? storing a function in an object

2009-07-20 Thread I V
On Mon, 20 Jul 2009 21:53:59 -0400, Esmail wrote: > In general I would agree with you, but in my specific case I want so > store some additional meta-data with each function, such as the valid > range for input values, where the max or minimum are located, the > name/source for the function etc. I

Re: comments? storing a function in an object

2009-07-20 Thread Carl Banks
On Jul 20, 9:22 am, Esmail wrote: > def funct1(x): >      ''' small test function ''' >      return x * x > > def funct2(x, y): >      ''' small test function ''' >      return x + y > > def funct3(x): >      ''' small test function ''' >      return 1000 + (x*x + x) * math.cos(x) > > def main():

Re: comments? storing a function in an object

2009-07-20 Thread Esmail
Hi Francesco, Those were great suggestions! Re 1: I used the __doc__ attribute to eliminate the parameter in the constructor as you suggested. Also, much easier to specify the character string with the actual function than later to match it up like I was. class Function(object

Re: comments? storing a function in an object

2009-07-20 Thread Esmail
Gabriel Genellina wrote: > If you follow the above suggestions, you'll see that your Function class becomes almost useless: a normal function already IS an object, so you don't have to wrap it inside ANOTHER object unless you need very special features. Hello Gabriel, In general I would agre

Re: comments? storing a function in an object

2009-07-20 Thread Gabriel Genellina
En Mon, 20 Jul 2009 14:44:16 -0300, Francesco Bochicchio escribió: On Jul 20, 6:22 pm, Esmail wrote: Hello all, I am trying to store a function and some associated information in an object so that I can later have series of functions in a list that I can evaluate one at a time. Right now

Re: comments? storing a function in an object

2009-07-20 Thread Francesco Bochicchio
On Jul 20, 6:22 pm, Esmail wrote: > Hello all, > > I am trying to store a function and some associated information in an > object so that I can later have series of functions in a list that I can > evaluate one at a time. > > Right now I am only storing the function itself, the number of > argumen

comments? storing a function in an object

2009-07-20 Thread Esmail
Hello all, I am trying to store a function and some associated information in an object so that I can later have series of functions in a list that I can evaluate one at a time. Right now I am only storing the function itself, the number of arguments it expects and its string representation. I m

Re: Storing a function

2008-05-25 Thread Gabriel Genellina
En Sun, 25 May 2008 18:00:12 -0300, Kuros <[EMAIL PROTECTED]> escribió: > Hi, > Hoping I could get some help with a python question. > > I want to be able to store the code for a single function in a .py file, > such as: > > def test(): > print "Test" > > From within a Python script, I would l

Storing a function

2008-05-25 Thread Kuros
Hi, Hoping I could get some help with a python question. I want to be able to store the code for a single function in a .py file, such as: def test(): print "Test" >From within a Python script, I would like to be able to get a handler so I can do something like: handler.test() I want to be