Skip to content

Tag: python

Pydantic Checking if list field is unique

Currently, I am trying to create a pydantic model for a pandas dataframe. I would like to check if a column is unique by the following I would now like to run a validation here and have it fail since address is not unique. The following returns what I need but i want to be able to reuse this validator

Python – Returning multiple functions from closures

I’m trying to emulate private variables in Python by using function closures. My idea was to define a factory function that returns multiple getters. In Javascript, I would write the following: Is there any way to do the same in Python(i.e., returning multiple function objects from a closure)? Answer So…

Lower execution time for apache log parser in Python

I have an school assignment where I were tasked with writing a apache log parser in Python. This parser will extract all the IP addresses and all the HTTP Methods using Regex and store these in a nested dictionary. The code can be seen below: This code works (it gives me the expected data for the log files we…

Pass multiple variables from one module to another

I have several modules in the folder “Programm/modules” which are called by another script in “Programm”. One for example looks like this: “calculate.py” this I would like to load into another module “print.py” But I get the error “ModuleNotFoundError: No …