Can i access the __dict__ object for the local scope in Python Programming Language?

editAnswer

reportReport

Answer(s) available: 1

Sadhil Deo

, Sales Representative (Computers), Continuous Improvement Project Management Skills

"

Dict returned by locals() (or globals()) is mutable, so you could do:

"
def get_dynamic_settings(context_dict):"
    context_dict['DEFAULT_FROM_EMAIL'] = '%s ' % context_dict['SITE_NAME']"
    context_dict['ROOT_URLCONF'] = 'mysite.urls.%s' % context_dict['SITE_SLUG']"
    context_dict['TEMPLATE_DIRS'] += (os.path.join(PROJECT_ROOT, "templates", context_dict['SITE_SLUG']),)"
"

thumb_upUpvote3

smsComment

reportReport