Every Python dev falls for this (name mangling)

mCoding
mCoding
137 هزار بار بازدید - 2 سال پیش - Don't fall for it!The Zen
Don't fall for it!

The Zen of Python must not have been invented yet because this feature is confusing, not obvious, implicit, and much more. Private name mangling in Python converts variable usages like __var into _ClassName__var at compile time and there's no warning it's happening until you run into the trap.

― mCoding with James Murphy (https://mcoding.io)

Source code: https://github.com/mCodingLLC/VideosS...
Python docs: https://docs.python.org/3/tutorial/cl...
CPython mangle: https://github.com/python/cpython/blo...

SUPPORT ME ⭐
---------------------------------------------------
Sign up on Patreon to get your donor role and early access to videos!
Patreon: mCoding

Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.)
https://www.paypal.com/donate/?hosted...

Want to donate crypto? Check out the rest of my supported donations on my website!
https://mcoding.io/donate

Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, Neel R, Matt R, Johan A, Casey G, Mark M, Mutual Information

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord: Discord: discord
Github: https://github.com/mCodingLLC/
Reddit: Reddit: mCoding
Facebook: Facebook: james.mcoding

CHAPTERS
---------------------------------------------------
0:00 Unexpected output
2:31 Private name mangling
4:23 Python does not have private variables
4:54 Mangling rules
6:51 Mangling at compile time
8:28 Compiler explorer
10:18 getattr and setattr
10:55 To mangle or not to mangle?
13:53 Thanks
2 سال پیش در تاریخ 1401/09/14 منتشر شده است.
137,016 بـار بازدید شده
... بیشتر