
Security News
Potemkin Understanding in LLMs: New Study Reveals Flaws in AI Benchmarks
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Helpers to get specific settings from a particular section of a settings.ini file
You must include at least one section header in your settings.ini file
(like [default]
). The configparser will raise a
MissingSectionHeaderError if no headers are defined.
If you have any additional section headers, each parsed section will
only contain things defined in that section, plus anything defined in
the special/optional [default]
section.
The values of any variable names in any sections can be overwritten by the value set for an environment variable of the same name (or it’s ALLCAPS name).
Any variables that have multiple values separated by a comma will be converted to a list.
The parsed values will be converted to their basic types (int, float,
None, bool, str) via the from_string
or string_to_converted_list
functions from input-helper <https://pypi.org/project/input-helper>
__
for easy use.
You can comment out any variables in the settings.ini file with a
leading #
.
Create a settings.ini
file next to your script with at least one
section header in square brackets (like [my stuff]
).
::
[my stuff] something = 100 things = none, true, false, 1, 2.5, dogs and cats, grapes
Use the simple get_all_settings
function to get a dict of all
settings by section header.
::
import settings_helper as sh
settings = sh.get_all_settings()
For our settings.ini file example, the settings dict from
get_all_settings()
would be the following:
::
{ 'my stuff': { 'something': 100, 'things': [None, True, False, 1, 2.5, 'dogs and cats', 'grapes'] } }
When dealing with settings where values are numbers, but you don’t want
them converted (i.e. version numbers like “3.10”), you can set kwarg
keep_num_as_string
to True
when calling get_all_settings
(or
settings_getter
).
::
import settings_helper as sh
settings = sh.get_all_settings(keep_num_as_string=True)
For our settings.ini file example, the settings dict from
get_all_settings(keep_num_as_string=True)
would be the following:
::
{ 'my stuff': { 'something': '100', 'things': [None, True, False, '1', '2.5', 'dogs and cats', 'grapes'] } }
Create a default/sample settings.ini
file in the module directory of
your package, with a [default]
section and any other [sections]
you want (i.e. app environments)
::
[default] something = 100
[dev] redis_url = redis://localhost:6379/1 something = 500
[test] redis_url = redis://localhost:6379/9 things = none, true, false, 1, 2.5, dogs
For this settings.ini file example, the settings dict from
get_all_settings()
would be the following:
::
{ 'dev': { 'something': 500, 'redis_url': 'redis://localhost:6379/1' }, 'default': { 'something': 100 }, 'test': { 'something': 100, 'redis_url': 'redis://localhost:6379/9', 'things': [None, True, False, 1, 2.5, 'dogs'] } }
Create a MANIFEST.in
file in your package directory with the
following
::
include settings.ini
Update the setup.py
file of the package to include the
setting.ini
file and add settings-helper
to install_requires
list
::
from setuptools import setup, find_packages
setup( name='package-name', version='0.0.1', ... packages=find_packages(), install_requires=[ 'settings-helper', ... ], include_package_data=True, package_dir={'': '.'}, package_data={ '': ['*.ini'], }, ... )
Note, your package directory tree will be something like the following
::
package-name ├── .gitignore ├── LICENSE.txt ├── MANIFEST.in ├── README.md ├── README.rst ├── package_name/ │ ├── init.py │ └── settings.ini └── setup.py
Use in __init__.py
of package
::
import settings_helper as sh
get_setting = sh.settings_getter(name) something = get_setting('something') something_else = get_setting('something_else', 'default_val')
Set APP_ENV
environment variable to be one of your section names
when starting your Python interpreter/server. APP_ENV
defaults to
dev
if it is not set.
get_setting
func will return the value of the requested
variable if it is set in the section specified in APP_ENV
.[default]
section[default]
section either, then
return the optional fallback value passed in the default
keyword
argument to get_setting
(which defaults to an empty string)The first time that settings_getter
func is invoked, it looks for a
settings.ini
file in ~/.config/<package-name>/settings.ini
.
::
import settings_helper as sh
settings = sh.get_all_settings(name)
or
::
import settings_helper as sh
settings = sh.get_all_settings(name).get(sh.APP_ENV, {})
The get_all_settings
func returns a dict containing all section
headers. ‘default’ .
In your <package-name>/tests/__init__.py
file, add the following so
the test
section of settings is automatically used
::
import os
os.environ['APP_ENV'] = 'test'
FAQs
Helpers to get specific settings from a particular section of a settings.ini file
We found that settings-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.