Re: How do I import everything in a subdir?

2005-03-06 Thread YL
Try something like this:
for x in plugs:
cmd = "import %s" % x
exec (cmd)


"Dfenestr8" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi.
>
> I have a program which I want a plugin directory for. I figured the way to
> go about that would be to just add a plugin/ dir to sys.path, and import
> everything in it. Then my program can just execute the main() method of
> each imported plugin.
>
> Is that a good way to go about it?
>
> If so, how do I import everything in the plugins dir? The method raises an
> error as you can see.
>
> >>> import sys
> >>> import os
> >>> sys.path.append("plugins")
> >>> ls = os.popen("ls plugins").readlines()
> >>> for x in ls:
> ... plugs.append(x[0:x.rfind(".py")])
> >>> for x in plugs:
> ... import x
> ...
> Traceback (most recent call last):
>   File "", line 2, in ?
> ImportError: No module named x
>


-- 
http://mail.python.org/mailman/listinfo/python-list


perform dynamic tasks for C/C++/ObjC programs

2006-02-02 Thread YL
I'm working on an expert system that allows dynamic updating of
expert's knowledge and logics. I use database to store the info about
how to evaluate user's responses to questionnaires. The core table
called EvaluationPoint whose records have
attributes(evaluation_point_id,questionnaire_id,pattern_id,config,status,...)

Once a record in table EvaluationPoint been fetched, it becomes an
object of class EvaluationPoint with virtual sub-type according to its
pattern specified by pattern_id. Where certain evaluation
pattern/procedure is defined (EvaluationPattern data are also
persistently stored in database for runtime management).

Each instance of EvaluationPoint's config value contains the parameters
etc. necessary to obtain the exact logic/procedure from its pattern.
EvaluationPoint and EvaluationPattern are managed by people who have
certain participations to the system and data.

My app is writtern in ObjC running on win2k. As compiled language,
there are limited flexibilities to handle dynamic logics/procedures. So
I'm thinking about store python code in my config value of
EvaluationPoint records whenever needed, and let python handle the
dynamic behavior of evaluationPoints.

I don't know if this make sense at all but if you have ideas or
examples about how to interact python from within C/C++/ObjC, please
advise me. Thanks a lot!

-- 
http://mail.python.org/mailman/listinfo/python-list