Bases: dict
Mapping object (subtype of dict) to store configurations.
Updates configuration from Python file. For example, if there’s dev.cfg:
debug = False
database_uri = 'sqlite://'
so you can load it using update_from_file() method:
config.update_from_file('dev.cfg')
Like update_from_object() method, it also ignores variables that start with underscore.
Parameters: |
|
---|
Updates configuration from arbitrary object_.
@config.update_from_object
class default_config:
debug = False
database_uri = 'sqlite://'
It ignores attributes that start with underscore and keys that already exist until overwrite is True.
Parameters: |
|
---|
Maps application properties to configuration values.
Finds the typename string of the given cls.
Parameters: | cls (type) – the class object to find its typename |
---|---|
Returns: | the typename |
Return type: | basestring |
This function provides a minimal language to import a class from a package/module and make an instance of it. For example, the following code:
val = import_instance('abc.defg:ClassName(3.14, hello, world=False)')
is equivalent to the following normal Python code:
from abc.defg import ClassName
val = ClassName(3.14, 'hello', world=False)
As you can see its syntax is slightly different from normal Python. You can pass arguments to class’ constructor using its own syntax. You can pass limited types of values:
You can 'single quote' and "double quote" both for string literals, and r'raw string literals' are also available. There are u'Unicode string literals' as well.
Moreover, if there re unquoted barewords these are also interpreted as strings.