Re: Access to static members from inside a method decorator?
no need for all that,i wrote a basic Ajax framework for cherrypy that features a Ajax.Net feature,exposing functions to JavaScript via attributes(or in python via decorators),here is a decorator that run one time(i.e. before running the actual code) and get the name of the class [code] def AddFunction(func): stack=inspect.stack() ClsName=stack[1][3]#get the class name from the stack #now you both have the ClassName and the func object,so you can populate your list return func#return the decorated function [/code] it use the module inspect,to inspect the stack. -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
use Eclipse!!! it is not a editor but it is the best free IDE out there. for python use Pydev(pydev.sf.net) plugin:it got EVERYTHING:completteion,debuging(with thread support)you can`t work without a debugger for serious projects. for Web Develop use Aptana(aptana.com) another plugin for eclipse,in eairly stages but it is very amazing support most of open source javascript library with auto-complete and outline of code. Scribes look very nice for a editor i will try it for lightweight editing. -- http://mail.python.org/mailman/listinfo/python-list
accepts decorator
i want to make a decorator that make a function accept only types,if the types are wrong but the number of types is equal to arguments try to convert them to the type. for example: @Accept(int,int) def Sum(a,b): return a+b print Sum("2",2.0) this should print 4,coz the decorator sees that there is the same amount of arguments in Accept and Sum,then it will try to cast them to the types(a to int and also b to int),then he will send them to the normal function so Sum will get a=2,b=2 instead of a="2"(string) b=2.0(float). i made this but it doesn`t work: def Accept(*types): def check_accepts(f): assert len(types) == f.func_code.co_argcount-1,"Not Enougth/Too much Types" Types=types def new_f(*args, **kwds): newArgs=[] for (a, t) in zip(kwds.values(), Types): try: newArgs.append(t(a)) except: raise Exception("Convertion of %s to type %s failed" %(a,t)) nargs=tuple(newArgs) return f(*nargs, **kwds) new_f.func_name = f.func_name return new_f return check_accepts it doesn`t work when i decorate a instance method. i get in *args the instance and in **kwds the arguments,but if it is just a function not a instance method i get in *args the arguments and in **kwds a empty dict. can someone also explain me what is * and ** ,and how they are called. Thanks, -Uriel Katz -- http://mail.python.org/mailman/listinfo/python-list
Re: accepts decorator
i think i got what the * and ** mean. *args mean arguments that are assigned by position(that is why *arg is a tuple) **kwds mean arguments that are assigned using equals a=2,b=3 (that is why **kwds i a dict) but why self is in *args and other thing goes to **kwds? even if not assigned using equals -- http://mail.python.org/mailman/listinfo/python-list
Re: accepts decorator
hehe i saw that,that is what made my understand it. the decorator now works. let say i have a function decorated with two decorators: @Accept(int,int) @OtherDecorator def myfunc(a,b): pass how can i make the two decorators into one(note:one get parameters and the other doesn`t) -- http://mail.python.org/mailman/listinfo/python-list
Re: object references/memory access
if both the search server and the web server/script are in the same computer you could use POSH(http://poshmodule.sourceforge.net/) for memory sharing or if you are in UNIX you can use mmap. this is way faster than using sockets and doesn`t require the serialization/deserialization step. -- http://mail.python.org/mailman/listinfo/python-list
Interop between C# and Python
i need a easy way to write a Python Service(be it SOAP or JSONRPC or whatever) but i need to easily access it from C#,i created a web service in ZSI(which is really easy) like this: from ZSI import dispatch def hello(): return "hello" dispatch.AsServer(port=8080) simple and easy but how i access it from C#,where is the wsdl for the service? is there any easier way to get this kind of interop?(not using a custom protocol over sockets) thx, Uriel Katz -- http://mail.python.org/mailman/listinfo/python-list
Re: Interop between C# and Python
thx i will try this. i am also trying XML-RPC,i wrote a basic generator(in python) that genrate a Interface from the XML-RPC service module,but maybe with soaplib i don`t need this if i use wsdl as Visual Studio can generate the code from the wsdl -- http://mail.python.org/mailman/listinfo/python-list
unittest dependencies
i am using unittest to test a project,and one thing i really want is a way to say that test a depends on test b,so it need to run before it and be successful in order to run this test. i just wanted to know if anyone have done it before(i searched for it but didn`t find something useful),i think it can be done easily using a decorator that will run the test which is depend on and mark it as successful,the only problem will be detecting circular test dependencies,but that can be fixed by keeping all the functions that the decorator have seen. what do you guys think? did someone did it before? -- http://mail.python.org/mailman/listinfo/python-list