Tag: python

Saving Gzip Files in Python

I have various Python applications that run periodically and deal with data in lists and dictionaries, and they save the processed and/or discovered data as JSON in text files for logging purposes or other later use. Typically the files are quite large and take up substantial amount of disk space. Since the applications run on […]

Selecting Pynetbox Version

If you have: And you need: Then you need to use: Because: NetBox 3.2.0 or newer /api/ipam/vlan-groups/<id>/available_vlans pynetbox 6.5.0 or newer Feature was added in NetBox 3.2 (not yet released) NetBox 3.1.1 or newer /api/ipam/prefixes/<id>/available_ips (or _prefixes) pynetbox 6.4.1 or newer NetBox behaviour was changed, pynetbox was updated to support that NetBox 3.1.0 or newer […]

Comparing Version Numbers in Python

The distutils module is going to be deprecated in Python 3.10, and to be removed in Python 3.12. Hence, my current standard way of comparing version number strings is using pkg_resources module (part of setuptools): >>> from pkg_resources import parse_version as version >>> version(“1.0”) <Version(‘1.0’)> >>> version(“1.8.9”) < version(“2.0”) True >>> version(“2.0.9”) < version(“2.1”) True […]