Tag: python

Revisited: Version Numbering in Python Package

In Version Numbering in Python Package I showed a way to store the package version number in the code. The method is in hindsight not exactly the best one (who knew!), so here is another try for simple projects. Here I have mypackage/ (the package directory) mypackage/__init__.py mypackage/version.py setup.py with contents: mypackage/version.py: mypackage/__init__.py: setup.py: What […]

Python Loggers

This is a memo about my current standard way of logging in Python, especially when multiple modules are involved. In the main application (app.py): When app.py is started it gets the root logger in line 7. In main() it sets the logging configurations: logging level, formatter and handler. Here the handler is just outputting to […]

Hints for Pynetbox

Note: I don’t yet have extensive experience on NetBox 2.9.x but these have been shown useful in earlier NetBox versions. I’ll update the page later if I find some further comments about the performance in NetBox 2.9.x. Speeding up fetching the devices Fetching lots of devices (hundreds or thousands, depending on the environment) with netbox.dcim.devices.all() […]

Pathlib in Python

I found pathlib standard library in Python just recently. It is a full set of classes, methods, properties and operators that make it very easy to work with files, directories and paths in operating system-independent way. You all do remember that not all filesystems use / (slash) as the path separator…? I had a specific […]