Functional/Best?
Tim Cook
timothywayne.cook at gmail.com
Sun Jul 13 09:39:05 EDT 2008
I guess I can classify my application(s) as more procedural than
anything else. But I have a question about the best way to handle
something in Python.
When given a mapping of keywords, I want to call a function based on a
certain keyword found when parsing a text file. The mapping looks like
this:
definClassMap={'SECTION':'bldSection','COMPOSITION':'bldComposition','OBSERVATION':'bldObservation','ITEM_TREE':'bldItemTree'}
So if the text file contains 'ITEM_TREE' I want to call bldItemTree
which creates an instance of the class ItemTree.
I currently use an if ..., elif ... construct.
Is there a better, more efficient, more Pythonic way of doing this?
Thanks,
Tim
--
**************************************************************************
Join the OSHIP project. It is the standards based, open source
healthcare application platform in Python.
Home page: https://launchpad.net/oship/
Wiki: http://www.openehr.org/wiki/display/dev/Python+developer%27s+page
**************************************************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Displayemail.gif
Type: image/gif
Size: 4274 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080713/dc704925/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20080713/dc704925/attachment.sig>
More information about the Python-list
mailing list