Re: egg and modpython

2006-09-11 Thread Wensheng
Paul Boddie wrote: > Bruno Desthuilliers wrote: > > Wensheng a écrit : > > > I installed pysqlite2 using easy_install. > > > and got this when using it from modpython: > > > -

egg and modpython

2006-09-08 Thread Wensheng
I installed pysqlite2 using easy_install. and got this when using it from modpython: -- Mod_python error: "PythonHandler etc.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/sit

simple AJAX with JSON

2005-10-03 Thread Wensheng
I just post a cookbook recipe on simple ajax. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440637 Hope someone find it's useful. Wensheng Wang -- http://mail.python.org/mailman/listinfo/python-list

Re: Loading functions from a file during run-time

2005-02-17 Thread Wensheng
f=open("bar.txt") import imp fs=imp.new_module("fs") exec f in fs.__dict__ rests are the same althought why use anything other than .py, when you import .py, it get compiled into .pyc and it load faster next time -- http://mail.python.org/mailman/listinfo/python-list

Re: Loading functions from a file during run-time

2005-02-16 Thread Wensheng
or don't use exec(): f=[getattr(fs,a) for a in dir(fs) if a[0:2]!='__' and type(getattr(fs,a))==types.FunctionType] >>> f [, ] >>> f[0](n) -5 >>> f[1](n) 25 -- http://mail.python.org/mailman/listinfo/python-list

Re: Loading functions from a file during run-time

2005-02-16 Thread Wensheng
#--- file bar.py def negate(n): return -n def square(n): return n*n #--- end bar.py >>> foo="bar" >>> fs=__import__(foo) >>> import types >>> f=[a for a in dir(fs) if a[0:2]!='__' and type(getattr(fs,a))==types.FunctionType] >>> f ['negate', 'square'] >>> n=5 >>> exec("print fs."+

Re: Loading functions from a file during run-time

2005-02-12 Thread Wensheng
if the file you want to include is not txt, but instead py, it should be easy. for example you have fs.py you just - fs=__import__("fs") f=[a for a in dir(fs) if a[0:2]!='__'] #no you have f1(),f2(),f3() as f[0],f[1],f[2] then excute desired function, for exampl

Re: how can I replace a execfile with __import__ in class to use self variables

2005-02-09 Thread Wensheng
I just realized I can pass the object itself: like p=__import__("printit") p.pr(self) in printit.py - def pr(self): print self.var --- -- http://mail.python.org/mailman/listinfo/python-list

how can I replace a execfile with __import__ in class to use self variables

2005-02-09 Thread Wensheng
I have a py program below: class someclass: def __init__(self): self.var = "hell, world" def printitout(self): execfile("printit.py") #__import__("printit") #doesn't work if __name__=="__main__":

opinions comments needed for improving a simple template engine.

2004-12-07 Thread Wensheng
Hi, I wrote a small template engine called spytee. Like any template enigne, it take a text(html) template file as input, process the variable tags in the file, and display the resulted text. The difference from most templates are: you can edit the template file in the html editor(Frontpage, Dreamw