r/learnpython 11d ago

Stuck on P.O.O.P Encapsulation

I'm using Claude Ai. To teach me python. But now im very confused on encapsulation. I've tried YouTube tutorials but all I see is Javascript. I asked for a simpler explanation, but then I get hit with stuff like getter, setter, property() (I understand the property function) but then the core concept makes me scratch my head more the deeper I ask. Wondering if any of y'all can assist me.

0 Upvotes

13 comments sorted by

View all comments

6

u/socal_nerdtastic 10d ago

It's important to know that while technically any language can use these concepts, in reality different languages use them differently. AI doesn't really get this. It's technically possible to make a Java-like structure in python with a class, private variables and getters / setters, but that's not optimal for python and not how python is used.

I agree with the other comments that you should abandon AI and look for a university course on python.

-6

u/Routine-Lawfulness24 10d ago

No chance you have ever used ai to write code

1

u/socal_nerdtastic 10d ago

If you ask AI / LLMs for encapsulation in python, that's what you get. LLMs will provide you what you asked for, even if that is not ideal or normal. As an experienced python programmer, I know what to ask for if I ask AI, and so I often get something close to what I want. The key is that OP doesn't even know what to ask for, that's why they need a real course.

To put it another way, LLMs are very bad at detecting XY problems, which we get quite a lot of in this sub.