By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,001 Members | 1,176 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,001 IT Pros & Developers. It's quick & easy.

Proper way of handling "plug-in" methods

P: n/a

My application deals with strings formatting. I have built-in methods
but I also expect the user to add its methods in its own .py files
(some sort of plugin methods, all user methods should be exposed in my

Here is the structure I have thought of :
_formattingDict = {} #a dict composed of all available methods, both
builtin and user
def expose(...) : #adds a method to the dict
import myapp.formatting.expose
def builtinMethod(inputStr) : return someOutput

import myapp.formatting.expose
def customMethod(inputStr) : return someOutput
#References all the methods, both builtin and custom

Expected result after the execfile : formatting._formattingDict
contains the 2 methods builtinMethod and customMethod

Is this a proper way of structuring my application ? Do you see
anything better ?

Moreover, I dislike execfile("") since classic
import would do the job. However I first wanted a united method for
both builtin and custom scripts since it is the same logic for me.

Thanks very much in advance for your advice.
Jan 8 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.