May 9, 2024, 12:08 a.m. | Brandon Michael Hunter

DEV Community dev.to

Here's what I learned today from studying Python.....


I didn't know defining a class property with '__' in Python its referred as private.


In this example the property '.__height', if you try to set it will throw an Attribute error.


`class Square:

def init(self):

self.height = 2

self.
width = 2

def set_side(self, new_side):

self.height = new_side

self.
width = new_side


square = Square()

square.__height = 3 # raises AttributeError `


There's a caveat...... You can still …

class error example property python set square studying will

Software Engineer for AI Training Data (School Specific)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Python)

@ G2i Inc | Remote

Software Engineer for AI Training Data (Tier 2)

@ G2i Inc | Remote

Data Engineer

@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania

Artificial Intelligence – Bioinformatic Expert

@ University of Texas Medical Branch | Galveston, TX

Lead Developer (AI)

@ Cere Network | San Francisco, US