SOLID Principles In 2025 In Practice With Python And UML Examples

Original title: SOLID Principles In 2025 In Practice With Python And UML Examples Because your future self deserves better code reviews. Why Should You Care About SOLID in 2025? Let’s be real: most developers nod politely when SOLID comes up, then continue writing 500-line classes that smell worse than week-old fried eggs. Here’s the thing: SOLID isn’t about pleasing your CS professor. It’s about writing code that your future self won’t want to rage-quit from after a single bugfix. Bad code means frustration, late nights, and way too much coffee. SOLID is a language that senior devs use to communicate across years of maintenance. When you see it in a project, you don’t need to crawl line by line like some code archaeologist digging through ruins. Instead, you can predict the system’s behavior, understand responsibilities, and trust that classes aren’t hiding surprises like a clown in a sewer drain. Follow it, and you can read code like a map. Ignore it, and you’re wandering blind through spaghetti caves. ...

August 29, 2025

Python : why am I getting nameError: name x is not defined

Original title: Python : why am I getting nameError: name x is not defined I’m just starting to learn Python, and I got this error message:

August 29, 2025

How to get the MCPO Proxy command working correctly

Original title: How to get the MCPO Proxy command working correctly Just trying to setup a basic MCP Server and put it behind MCPO proxy. This MCP server copied from: https://github.com/modelcontextprotocol/python-sdk/tree/main """ FastMCP quickstart example. cd to the examples/snippets/clients directory and run: uv run server fastmcp_quickstart stdio """ from mcp.server.fastmcp import FastMCP Create an MCP server mcp = FastMCP(“Demo”) Add an addition tool @mcp.tool() def add(a: int, b: int) -> int: “““Add two numbers””” return a + b ...

August 29, 2025

How to do linear interpolation in PySpark without Pandas UDF (only using Spark API)?

Original title: How to do linear interpolation in PySpark without Pandas UDF (only using Spark API)? I have a Spark DataFrame with the following structure: shock_rule_id DATE value A 2024-01-01 100 A 2024-01-02 null A 2024-01-03 130 B 2024-01-01 50 B 2024-01-02 null B 2024-01-03 null B 2024-01-04 80 I want to perform linear interpolation of the value column within each shock_rule_id group. I don’t want to use Pandas UDF – I’d like to do this using only Spark API / SQL functions. My DataFrame contains only business-day dates (no weekends/holidays). I already wrote one approach using Spark SQL window functions (first, last, row numbers, etc.) like this (simplified): ...

August 29, 2025

How to typehint functools.partial classes

Original title: How to typehint functools.partial classes I’m struggling to type hint correctly a python dataclass (or any class) with partial initialization, it seems that the type is lost somewhere but not sure where: from dataclasses import dataclass from functools import partial @dataclass class Test: a : int b : int @classmethod def test_partial[T: Test](cls: type[T], b:int) -> partial[T]: return partial(cls, b=b) @classmethod def test_partial2(cls, b:int): return partial(cls, b=b) part = Test.test_partial(3) part( # linter suggest nothing when passing here ...

August 29, 2025

Why is my list not updating inside a function in Python?

Original title: Why is my list not updating inside a function in Python? I’m trying to modify a list inside a function, but the changes don’t seem to persist outside the function. Here’s a simplified version of my code: def update_list(my_list): my_list = my_list + [4, 5] original_list = [1, 2, 3] update_list(original_list) print(original_list) What I tried: I defined a function that takes a list and attempts to add elements to it using my_list = my_list + [4, 5]. I then passed an existing list [1, 2, 3] to the function and expected the function to modify it. What I expected: I expected the original list to be updated to [1, 2, 3, 4, 5] after calling the function. What actually happened: The list remained [1, 2, 3] after the function call. The changes didn’t persist outside the function. ...

August 29, 2025

Pandas read_csv: Skip rows contains invalid data that can cause data_type parsing errors

Original title: Pandas read_csv: Skip rows contains invalid data that can cause data_type parsing errors The csv file can contain string values to certain integer columns and i want to ignore/handle via callback if that happens, tried using on_bad_lines=‘skip/warn’ however it gets triggered only on wherever there are parsing issues due to delimiter/num of columns mismatch. Here is the code i am using csv: id,name,age 1,,“25” 2,"",30 jj,John, import pandas as pd schema = {‘id’:‘int64’,’name’:‘str’,‘age’:‘int’} df = pd.read_csv(‘a.csv’, dtype=schema, on_bad_lines=‘warn’, engine=‘python’) ...

August 29, 2025

How to deploy Python+HTML using AWS EC2 and GitBash [closed]

Original title: How to deploy Python+HTML using AWS EC2 and GitBash [closed] I have currently been working on projects developed using Microsoft Visual Studio 2022, using Python and HTML code as a web-app. However, when I deployed to EC2, only my HTML files are working, the backend logics of Python are not working at all. In my expectation, that should be a comprehensive and working web application, that can help run my program online. ...

August 29, 2025

How to add a value to a whole list, but except specific values?

Original title: How to add a value to a whole list, but except specific values? I wish to have a list of numbers, e.g. [3,6,-1,8,2,-1] and be able to add 2 to all elements except the -1s, for example, to get [5,8,-1,10,4,-1]. I’ve managed to add values to all elements, but have been unable to except values, which I think is due to me being unable to define specific elements within the code. ...

August 29, 2025

My django app broke after windows reinstallation

Original title: My django app broke after windows reinstallation Yesterday I reinstalled Windows and now my Django project’s Google login (using django-allauth v0.65.11) stopped working. I use a virtual environment and reinstalled the same dependencies (pip freeze matches exactly). Before the Windows reinstall, everything worked fine. Now, when I try to log in with Google, I get this error on the website: Third-Party Login Failure An error occurred while attempting to login via your third-party account. ...

August 29, 2025