import and package confusion
Dale Amon
amon at vnl.com
Thu Apr 30 10:35:50 EDT 2009
Gabriel gave me the key to a fine solution, so
just to put a bow tie on this thread:
#!/usr/bin/python
import sys
sys.path.extend (['../lib', '../bin'])
from VLMLegacy.CardReader import CardReader
rdr = CardReader ("../example/B767.dat","PRINTABLE")
iotypes = ["WINGTL","VLMPC","VLM4997"]
for iotype in iotypes:
classname = "Conditions"
__import__("VLMLegacy." + iotype + "." + classname)
module = sys.modules[packagename]
cls = getattr(module, classname)
a = cls(rdr,2)
a.test()
Works like a champ!
It would have taken days for me to find that by trial and
error and rtfm and google. So thank you all. Even if at times
I was rather unclear about what I was trying to accomplish.
Now I can move on to parsing those pesky Fortran card
images... There wouldn't happen to be a way to take n
continguous slices from a string (card image) where each
slice may be a different length would there? Fortran you
know. No spaces between input fields. :-)
I know a way to do it, iterating over a list of slice sizes,
perhaps in a list comprehension, but some of the august python
personages here no doubt know better ways.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20090430/06dfb5a2/attachment.sig>
More information about the Python-list
mailing list