Re: who to call a list of method inside the class itself


Edwin.Madari@VerizonWireless.com wrote:

> 1. return string names of required methods in getMethod
> return ['method1', 'method2', 'method3']
> 2. use gettattr on self and then exetute methods in apply
> def apply(self):
> for method_name in self.getMethod():
> method = gettattr(self,method_name)
> method() #execute method now

why



Posted On: Wednesday 7th of November 2012 12:28:35 PM Total Views:  366
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




Re: Non-evil multithreaded WSGI server?

Gabriel Genellina wrote: > En Tue, 26 Aug 2008 03:20:53 -0300, Gerhard Häring > escribi: > >> In a recent experiment I've done this: >> >> from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler >> from wsgiref.simple_server import make_server, demo_app >> from SocketServer import ThreadingMixIn >> >> # Let's make a WSGI server that can use multiple threads. >> >> class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): >> """Handle requests in a separate thread.""" >> >> # Evil! ;-) >> from wsgiref.simple_server import WSGIServer as MyWSGIServer >> MyWSGIServer.__bases__ = (ThreadedHTTPServer,) >> >> Now I wonder if there's a less evil way that does not involve copy & >> paste of the WSGIServer code (only couple of lines, but I hate >> duplication)! > > I'm not sure I understand completely the question - does the code below > work for you > > class MyWSGIServer(ThreadingMixIn, wsgiref.simple_server.WSGIServer): > pass Yes, it does! I was totally on the wrong track. Of course the ThreadingMixin can also be "mixed in" later in the chain. -- Gerhard
VIEWS ON THIS POST

145

Posted on:

Wednesday 7th November 2012
View Replies!

Utah Open Source Conference, August 28-30

Apologies if this is too regional and not of interest to the broader Python community, but I felt I should pass along the link to an event I stumbled across today: http://2008.utosc.com/pages/home/ Some talks on the schedule are either directly about Python ("Vim and Python", "Using Lasers, Webcams, and Python to Create a Halloween Game in my Driveway") or about related topics ("A Django Miscellany"), not to mention all the general open-source topics. If you're in the neighborhood of Salt Lake Community College later this week and have the time, it might be worth a visit. I'm not connected with the event in any way. Just found it and wanted to share the info. Cheers! Justin
VIEWS ON THIS POST

151

Posted on:

Wednesday 7th November 2012
View Replies!

Re: Ensure only single application instance.

On Fri, Aug 29, 2008 at 6:51 AM, Heston James wrote: > Good afternoon all. > > I have an application/script which is launched by crontab on a regular > basis. I need an effective and accurate way to ensure that only one instance > of the script is running at any one time. > > After a short look around the internet I found a couple of examples, such as > this one (http://code.activestate.com/recipes/474070/), however they both > seem to be focused on a windows based environment. > > Can anyone offer their advice on how best to do this on a linux based > system > > I have been contemplating the idea of creating a pidfile which is destroyed > at the end of the script, will this suffice is it fool proof My only > concern with this is that if the script crashes or is stopped halfway > through processing for whatever reason, I'll be left with a dead pidfile on > the system and no successive runs will work. > > I'm really interested to get your ideas ,
VIEWS ON THIS POST

137

Posted on:

Wednesday 7th November 2012
View Replies!

python - firefox dom/xpath question/issue

Hi. Got a test web page, that basically has two "
VIEWS ON THIS POST

156

Posted on:

Wednesday 7th November 2012
View Replies!

Re: posix semaphore support?

Christian Heimes wrote: > Neal Becker wrote: >> Is there a posix semaphore wrapper for python >> >> Would that be a good addition > > The threading module provides a high level interface to native > semaphores, e.g. pthread. > > Christian > Does that provide semaphores between unrelated processes
VIEWS ON THIS POST

131

Posted on:

Wednesday 7th November 2012
View Replies!

posix semaphore support?

Is there a posix semaphore wrapper for python Would that be a good addition
VIEWS ON THIS POST

233

Posted on:

Wednesday 7th November 2012
View Replies!

translating "create Semaphore" to Linux

hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,"stringincludinginterfaceandport") rt=win32event.WaitForSingleObject (hSem, 0) if rt != win32event.WAIT_TIMEOUT: really_do_start_my_app() else: print "application allready running" to make sure that only ONE instance of the application is running at a time. (as it implements a local webserver, that is necessary. Two webservers listening on one port is bad) Now I am going to make this application run on Linux. How can I get similiar behaviour on Linux I know of the .pid files that get written by some server processes ... BUT they do not get cleaned up on unclean shutdown of the application. is there some better method Or some module which wraps the details of .pid-files quite nicely (like "trying to remove to check if other instance is still running...., failing properly on missing write privs etc.) best wishes, Harald
VIEWS ON THIS POST

182

Posted on:

Wednesday 7th November 2012
View Replies!

Python Google Chart 0.2.1 released

pygooglechart 0.2.1 has been released. http://pygooglechart.slowchop.com/ Here are the changes: * Added support for QR Code chart (#8) * Added legend positioning (chdlp) (Steve Brandt) * Added line styles (chm=D) (Steve Brandt) * Added "colours within series" option to chart (chco=xxx|xxx) (Steve Brandt) * Added QR codes and more line examples * Axis labels are now casted to strings automatically * Bug fixed where pie charts stopped working due to automatic scaling * Bug fixed where the module would download twice (#7) (Evan Lezar) * Bug fixed when automatic scaling is on and None values are in a data set (#5) (Alec Thomas) * Bug fixed with auto-scaling, where the minimum y range was always 0. (#6) (Rohit Jenveja) * Bug fixed, replaced "1" with "0" in add_horizontal_range and add_vertical_range (incorrect syntax for Google) (Steve Brandt) * Better clipping checks I've also updated the home page with more examples. Gerald -- Gerald Kaszuba http://geraldkaszuba.com/
VIEWS ON THIS POST

160

Posted on:

Wednesday 7th November 2012
View Replies!

hr.rec.kladjenje,rec.pets.cats.anecdotes

hr.rec.kladjenje,rec.pets.cats.anecdotes
VIEWS ON THIS POST

142

Posted on:

Wednesday 7th November 2012
View Replies!

Getting references to obect instances into a list

I would like to get the references to objets to put in a huge data structure (like a list or a heap for example). My objective is to use as less memory as possible as I have to manage huge amount of entries in my data structure and need to use the same elsewhere. If I were coding in C++, it would be natural to do so but as I am a newby to Python, I don't know yet how to achieve that. Can anyone help me with that
VIEWS ON THIS POST

171

Posted on:

Wednesday 7th November 2012
View Replies!

How to know a top directory?

there, Help me please. How to know a top directory I mean I have path "/this/ is/path" and I wanna get "/this/is". Also I want to use it as platform independent. If I want to pass "c: \that\path" then I need to get "c:\that". Does anyone have ideas
VIEWS ON THIS POST

383

Posted on:

Wednesday 7th November 2012
View Replies!

atomic increment

how can i do an atomic read+increment something like with lock: old = atomic_int atomic_int += 1 but in one operation
VIEWS ON THIS POST

129

Posted on:

Wednesday 7th November 2012
View Replies!

Is tempfile.mkdtemp() thread-safe?

, I'm using tempfile.mkdtemp() in a multithreading program and I've been having problems with it. Sometimes it tells me the file I'm trying to access (in the directory created with tempfile.mkdtemp()) doesn't exist. I suspect that tempfile.mkdtemp() returns the same directory to different threads sometimes. Does anyone know anything about this or have a solution I have to create unique and temp. directories to use an external program that creates a temp. file with the same name every time, thus if I want to call it from several threads, each call has to be from a different directory. Thank you, Gabriel
VIEWS ON THIS POST

144

Posted on:

Wednesday 7th November 2012
View Replies!

Re: Non-evil multithreaded WSGI server?

En Tue, 26 Aug 2008 03:20:53 -0300, Gerhard Häring escribi: > In a recent experiment I've done this: > > from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler > from wsgiref.simple_server import make_server, demo_app > from SocketServer import ThreadingMixIn > > # Let's make a WSGI server that can use multiple threads. > > class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): > """Handle requests in a separate thread.""" > > # Evil! ;-) > from wsgiref.simple_server import WSGIServer as MyWSGIServer > MyWSGIServer.__bases__ = (ThreadedHTTPServer,) > > Now I wonder if there's a less evil way that does not involve copy & > paste of the WSGIServer code (only couple of lines, but I hate > duplication)! I'm not sure I understand completely the question - does the code below work for you class MyWSGIServer(ThreadingMixIn, wsgiref.simple_server.WSGIServer): pass def make_server( host, port, app, server_class=MyWSGIServer, handler_class=WSGIRequestHandler): return wsgiref.simple_server.make_server(host, port, app, server_class, handler_class) -- Gabriel Genellina
VIEWS ON THIS POST

279

Posted on:

Wednesday 7th November 2012
View Replies!

subprocess seems to "detach" / ignore wait()

, it seems that child.wait() is ignored when print "Server running [PID %s]"%(child.pid) fpid.write(child.pid) are between the process creation child = Popen(cmd.split(), stderr=flog) and child.wait(). It seems to be a bug, doesn't it Mathieu (I'm running x11vnv with args in the cmd string on FreeBSD 8.0/CURRENT) flog = open(logfile, 'w') fpid = open(pidfile, 'w') try: child = Popen(cmd.split(), stderr=flog) print "Server running [PID %s]"%(child.pid) fpid.write(child.pid) child.wait() except KeyboardInterrupt: print "INT sent to vnc server" finally: fpid.close() flog.close() os.remove(pidfile) os.remove(logfile) sys.exit(0)
VIEWS ON THIS POST

126

Posted on:

Wednesday 7th November 2012
View Replies!

Empece hacer un blog de python " http://binsd.wordpress.com/ "

La verdad que me da un poco de vergenza pero bueno no se como colaborar con la comunidad python entonces empec hacer conjunto de entradas en mi blog para todos aquellos que recin se inician en python.Aun no llegue a explicar objetos pero estara bueno que me digan si voy por buen camino :-). Desde ya muchas gracias y perdn por las molestias. la direccion del blog es http://binsd.wordpress.com/
VIEWS ON THIS POST

242

Posted on:

Wednesday 7th November 2012
View Replies!

[ANNOUNCE] pygtkmvc-1.2.2 has been released

Version 1.2.2 of pygtkmvc has been released. Project homepage: Download: ============== About pygtkmvc ============== pygtkmvc is a fully Python-based implementation of the Model-View-Controller (MVC) and Observer patterns for the PyGTK2 toolkit. MVC is a pattern that can be successfully used to design and develop well structured GUI applications. The MVC pattern basically helps in separating semantics and data of the application, from their representation. The Observer pattern helps to weaken dependencies among parts that should be separated, but need to be connected each other. pygtkmvc provides a powerful and still simple infrastructure to help designing and implement GUI applications based on the MVC and Observer patterns. The framework has been designed to be: * Essential and small, it does only what it was designed for. * Not an external dependency for your application: it fits in 80KB and can be released along with it. * Easy to understand and to use; fully documented. * Portable: straightly runs under many platforms. License: LGPL =================== About release 1.2.2 =================== This is a minor release that fixes two major bugs about adapters. A few new examples about adapters have been also added.
VIEWS ON THIS POST

202

Posted on:

Wednesday 7th November 2012
View Replies!

Boost Python DLL from Boost Pro is built incorrectly?

I'm having issues with Boost Python, downloaded via http://www.boostpro.com. I *think* it's related to WinXP side by side assemblies. My application that uses Boost Python fails to start. I ran dependancy walker on the Boost Python DLL and I get the following: Error: The Side-by-Side configuration information for "c:\data\excds \test adaptation\BOOST_PYTHON-VC80-MT-1_35.DLL" contains errors. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem (14001). Error: At least one required implicit or forwarded dependency was not found. Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module. I removed the installation of the 1.35 binaries and reverted to 1.34.1, rebuilt my app and it works fine. So I think there's a problem with the 1.35 Boost Python DLL from Boost Pro. Could someone verify
VIEWS ON THIS POST

145

Posted on:

Wednesday 7th November 2012
View Replies!

Re: What parts of C:\Python25 are important?

Robert Dailey wrote: > I've currently embedded the python interpreter into a C++ application of > mine. I want to bundle the python core library with my application so > the user does not have to install python to use my application. What > files do I need to copy over Help is appreciated, thank you. off the top of my head: - python25.dll (from \windows\system32, usually) - any extension PYD:s and DLL:s you're using (from \python25\DLLs) - either the contents of the standard library (\python25\Lib) in PY and/or PYC form, or a zipped archive that contains all the PYC files in there (zipped relative to \python25\Lib). - (optional) MSVCR71.dll (but that's usually already installed, afaik) you also need to make sure that your application sets an appropriate path before it starts importing things, either by munging sys.path via embedded Python code, or via a call to Py_SetPythonHome. the comment block at the top of http://svn.python.org/projects/pytho.../PC/getpathp.c explains how the default path is created on Windows. in some cases, it helps to tell Python not to import the "site" module by itself, and then import site when you've set everything up. to do that, insert "-S" in the argv buffer before calling PySys_SetArgv. you may also want to remove any PYTHON-related environment variables from the local environment, before initializing Python.
VIEWS ON THIS POST

181

Posted on:

Wednesday 7th November 2012
View Replies!

Re: Tkinter - How to create combo box using Tix with the existingTkinter widgets/

On Mon, Aug 25, 2008 at 12:57 PM, wrote: > > > I'm using Tkinter module to create a GUI application. I found that the > combo box is not present in Tkinter module. > It comes with Tix module. Could some one give me an example to create > a combo box whilst using Tix and Tkinter > > I've been using the following to create my tkinter widgets: > myRoot = Tk() > > and in my Gui code, I've been using > self.lb****ysisLib = Listbox(master, \ > yscrollcommand = self.vsb****ysisLib.set,\ > height = 1, > width = 30) > > Please suggest how could I call the Tix's combo box from my existing > GUI application that heavily uses the Tkinter widgets > Kindly provide me some code examples. > >
VIEWS ON THIS POST

175

Posted on:

Wednesday 7th November 2012
View Replies!