| documentation: | http://easydev-python.readthedocs.io/en/latest/ |
|---|---|
| contributions: | Please join https://github.com/cokelaer/easydev |
| source: | Please use https://github.com/cokelaer/easydev |
| issues: | Please use https://github.com/cokelaer/easydev/issues |
| Python version supported: | 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 |
The easydev package provides miscellaneous utility functions and classes that are repeatedly useful during the development of Python packages. The goal is to help developers speed up their work by providing ready-to-use tools for common tasks such as parameter validation, logging, progress bars, configuration files, multiprocessing, and more.
It has been used as an incubator for other packages (e.g., colormap) and is used in projects such as bioservices, sequana, and GDSCTools.
Install the latest release from PyPI:
pip install easydev
- Parameter validation –
check_param_in_list,check_range - Dictionary utilities –
swapdict,AttrDict(access dict keys as attributes, supports nested dicts) - Logging – coloured logging via
Loggingclass - Progress bar –
Progressworks in Python, IPython, and Jupyter notebooks - Timer – measure elapsed time with the
Timercontext manager - Profiling –
do_profiledecorator usingline_profiler - Configuration files –
CustomConfigandDynamicConfigParserfor INI-style config management - Shell commands –
shellcmdandexecutewrappers around subprocess/pexpect - File utilities –
touch,mkdirs,md5 - Multiprocessing –
MultiProcessingclass for easy parallel job execution - Codecs –
to_list,list2stringand other conversion helpers - URL utilities –
isurl_reachableand related helpers - Sphinx integration – bundled Sphinx theme and
copybuttonextension
Parameter validation:
from easydev import check_param_in_list, check_range
check_param_in_list("on", ["on", "off"]) # passes silently
check_range(0.5, 0, 1) # passes silently
AttrDict – access nested dictionary keys as attributes:
from easydev import AttrDict
d = AttrDict(**{"server": {"host": "localhost", "port": 8080}})
print(d.server.host) # localhost
d.server.port = 9090
Coloured logging:
from easydev import Logging
logger = Logging("myapp", "WARNING")
logger.warning("something went wrong")
logger.debug("not shown at WARNING level")
logger.level = "DEBUG"
logger.debug("now it is shown")
Progress bar:
from easydev import Progress
pb = Progress(100)
for i in range(100):
# do work here
pb.animate(i + 1)
Timer:
from easydev import Timer
import time
times = []
with Timer(times):
time.sleep(0.1)
print(f"elapsed: {times[0]:.2f}s")
Multiprocessing:
from easydev.multicore import MultiProcessing
def square(n):
return n * n
t = MultiProcessing(maxcpu=4)
for i in range(10):
t.add_job(square, i)
t.run()
print(t.results)
| Version | Description |
|---|---|
| 0.13.3 |
|
| 0.13.2 |
|
| 0.13.1 |
|
| 0.13.0 |
|
| 0.12.2 |
|