Paul Boddie wrote:
> Bruno Desthuilliers wrote:
> > Wensheng a écrit :
> > > I installed pysqlite2 using easy_install.
> > > and got this when using it from modpython:
> > > -
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
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
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
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
#--- 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."+
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
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
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__":
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
10 matches
Mail list logo