Share your repls and programming experiences

← Back to all posts
Prototypal OOP in Python
AmazingMech2418 (1085)

Yes, you read that right! This post includes an example of prototypal object-oriented programming in Python, a language known for classical OOP.

Using basic object manipulation, I have figured out how to create a "pseudo-class" in Python, and here, you can see a demo of it, also including a prototypal inheritance structure!

Comments
hotnewtop
DynamicSquid (4913)

What's prototypal OOP?

AmazingMech2418 (1085)

@DynamicSquid Basically, making a "class" without using a class. Like with JavaScript when you make a "class" using a function! This is actually kind of modelled off of JS prototypal OOP, but JS at least has the native this keyword so you don't have to define a new object, and object construction is different too, and JS has anonymous functions too, so that makes it easier. LOL!

AmazingMech2418 (1085)

@DynamicSquid Thank you and you're welcome! :D