On Mon, Jul 7, 2014 at 9:14 PM, YaRoKe <[email protected]> wrote:
> That is how I do it as well, but I want to have a more dynamic version of
> this which *automatically* detects those modules in a folder and
> adds them to the URLs List.
>
explicit is better than implicit.
You can have a small utility function to make that job easier, but having
some magic to automatically add them is not a good idea.
# Warning: not tested
def flatten(lists):
return [x for lst in lists for x in lst]
def add_urls(module):
global urls
modname = module.__name__
urls += flatten((pattern, modname + "." + classname) for pattern,
classname in web.group(module.urls, 2))
import mod1
add_urls(mod1)
import mod2
add_urls(mod2)
Anand
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.