u/1k5slgewxqu5yyp

Coming from 4 years of procedural / functional programming, I can't wrap my head around OOP.

Hello, r/learnpython,

I am a mid level Data Scientist / Software Engineer and I have worked the last 4 years of developing statistical libraries, mainly in R and C. Due to the market and the direction my company is taking, I am being pushed to start developing in Python, but I have never (???) written proper OOP Python libraries in production.

And yes, I know R has S3, S4, R6, S7, etc, I just don't like to use them as the ecossystem is not concise in OOP matters.

I have written lots of Python in production, but it was either backend, or just more procedural type pipelines.

Let's say I want to create a library (kind of like an ORM?) where I have some queries I make all the time and want to be able to pass parameters to those queries and retrieve the data. In R, for something like this, I would design the API like:

```{r}

#' u/export

get_full_data_list <- function(connection, database, country, ...) {

# NOTE: These will also be public with `@export` and `@inheritParams` from

# main

df1 <- get_df1(connection, database, country, ...)

df2 <- get_df2(connection, database, country, ...)

df3 <- get_df3(connection, database, country, ...)

list(

df1,

df2,

df3

)

}

```

This would create a public function exported to the user he can just call. I would also `@export` all of the getters for the df1, 2 and 3, so users could call them on their own.

How would I do this in Python with proper OOP style architecture? I was thinking of the UX to be:

```python
from pkg import MyConnection

conn = MyConnection(
connection = "databricks",
database = "gold_layer",
country = "Spain"
)

# `...` being aditional params needed for the query specifically
df1 = conn.get_df1(...)
```

But then, I would have to do something like:

```python
class MyConnection:
def __init__(self, conn, database, country):
self.conn = conn
self.database = database
self.country = country

def get_df1(self, *args, **kwargs):
# This would replace the args in f strings
query = get_df1_query(self, *args, **kwargs)
return execute_query1(self, query)

def _get_df1_query(self, *args, **kwargs):
# The f string stuff
pass
```

This seems like everything is going to be on the same file, and I feel like I am missing some other abstraction layer and other class for this to be ok-ish to ship and easy to maintain down the line.

Thank you so much, I am banging my head on the wall lol

reddit.com
u/1k5slgewxqu5yyp — 8 days ago

Hello, r/FengShui,

First of all, I don't have a software for plant drawing, nor I have my father's house plant to show you, but recreated it with this .md file.

The thing is, my father really needs a remake of his house's furniture as the configuration we have now is NOT working at all.

I really do not know what to do, especially with the living room, but also the 2 bedrooms.

The WC and Kitchen have been renovated, so investing more money in reorganizing things would not bring much benefit.

Would really to see what you would come up with for these 3 divisions... Since I really do not know anything about how things should be placed for the place to be open and breathable.

Thank you so much!

NOTE: W stands for windows and D for Doors. TS is the toiled seat and bidet.

u/1k5slgewxqu5yyp — 16 days ago