compile your python programs with rpython

2007-01-15 Thread Simon Burton
The pypy'ers have written a brief description on using rpython to create standalone executables: http://codespeak.net/pypy/dist/pypy/doc/standalone-howto.html This is definately worth playing around with, it's very nice writing (r)python code that gets executed as if it were c code. Simon. --

Re: find class where method was defined ?

2006-09-19 Thread Simon Burton
def methclass(meth): cls = meth.im_class name = meth.im_func.__name__ meth = getattr(cls,name,None) for cls in cls.mro(): _meth = getattr(cls,name,None) if _meth is not None and _meth==meth: result = cls return result >>> methclass(b.foo) (Turns

find class where method was defined ?

2006-09-19 Thread Simon Burton
>>> >>> class A(object): ... def foo(self): pass ... >>> >>> class B(A): ... pass ... >>> >>> b=B() >>> b.foo > How can I work out what class b.foo was defined in ? Simon. -- http://mail.python.org/mailman/listinfo/python-list

realization: no assignments inside expressions

2006-05-18 Thread Simon Burton
I've been doing a little c programming again (ouch!) and it's just hit me why python does not allow assignment inside expressions (as in c): because it is absolutely essential that all assignments are as visible as possible. In python the assignment is the declaration; when declarations are as che

PyCon Vs. Europython

2006-01-18 Thread Simon Burton
the more esoteric python projects, such as the AST integration, and PyPy. Participating in a sprint would be brilliant. The line-up of talks at this year's PyCon looks more interesting to me, compared to Europython 2005. thanks, Simon Burton. -- http://mail.python.org/mailman/listinfo/p

linking one extension module to another (Mac OSX)

2005-11-21 Thread Simon Burton
Hi, I'm having some trouble linking one extension module to another because the linker expects a "lib" prefix and my python modules cannot have this prefix. I found two ways of doing it on a linux box (either symlink or create a dummy .so that links to extension module) but I can get neither of

Re: namespace dictionaries ok?

2005-10-25 Thread Simon Burton
In my case the deeply nested function calls are recursive calls for a tree traversal. This is similar to the visitor design pattern, where the Context class above is the Visitor. The difference is that the Context instance does not "visit" or "act" upon the nodes, but just stores state/context info

Re: namespace dictionaries ok?

2005-10-24 Thread Simon Burton
Yes! I do this a lot when i have deeply nested function calls a->b->c->d->e and need to pass args to the deep function without changing the middle functions. In this situation I think i would prefer this variation: class Context(dict): def __init__(self,**kwds): dict.__init__(self,kwds)

how to use new AST goodies

2005-10-24 Thread Simon Burton
Hello, i've just found out that the ast-branch has been merged into the main python cvs. ** Woohoo ! ** I'd like to experiment with this, does anyone know where to start ? It seems that the parser module still produces the same junk as before. So where do we find these nice high level AST objects

Re: namespaces

2005-08-09 Thread Simon Burton
ict__["__all__"] = dir(master) def __getattr__(self, name): attr = getattr( self._master, name ) return attr # ... end of file: sys.modules["mymod"] = ModuleProxy("mymod",sys.modules["mymod"]) --Simon Burton -- http://mail.python.org/mailman/listinfo/python-list

if not DEBUG: log = null_log

2005-07-12 Thread Simon Burton
uot; [2], but i don't quite see how i can use it while maintaining python source compatability. bye! Simon. [1]: http://occs.cs.oberlin.edu/~jwalker/nullObjPattern/ [2]: http://students.ceid.upatras.gr/~sxanth/pyc/ -- Simon Burton, B.Sc. Licensed PO Box 8066 ANU Canberra 2601 Australia Ph