Converging Multiple Classes
George Silva
georger.silva at gmail.com
Fri Feb 4 11:54:20 EST 2011
Take a look at the strategy pattern. But with python being a dinamic
language, you probably won't need to implement it like that.
http://en.wikipedia.org/wiki/Strategy_pattern
Example:
# import all you need
CAMERAS = ['A','B','C']
def capture_A:
pass
def capture_B:
pass
def capture_C:
pass
def capture(camera):
if camera in CAMERAS:
if camera = 'A':
function = capture_A
if camera = 'B':
function = capture_B
if camera = 'C':
function = capture_C
# call function
function()
else
return
On Fri, Feb 4, 2011 at 2:39 PM, Wanderer <wanderer at dialup4less.com> wrote:
> I have a bunch of cameras I want to run tests on. They each have
> different drivers and interfaces. What I want to do is create python
> wrappers so that they all have a common interface and can be called by
> the same python test bench program. I'm not sure what to call it. I
> don't think it's inheritance. Maybe there is no official thing here
> and I just need to brute force my way through it. Is there some
> programming methodology I should be using?
>
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
George R. C. Silva
Desenvolvimento em GIS
http://blog.geoprocessamento.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110204/c7f74e2c/attachment-0001.html>
More information about the Python-list
mailing list