In this Python Object-Oriented Tutorial, we will be learning about special methods. These are also called magic or dunder methods. These methods allow us to emulate built-in types or implement operator overloading. These can be extremely powerful if used correctly. We will start by writing a few special methods of our own and then look at how some of them are used in the Standard Library. Let's get started.
Python Docs: https://docs.python.org/3/reference/datamodel.html#special-method-names
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python OOP 2 - Class Variables - https://youtu.be/BJ-VvGyQxho
Python OOP 3 - Classmethods and Staticmethods - https://youtu.be/rq8cL2XMM5M
Python OOP 4 - Inheritance - https://youtu.be/RSl87lqOXDE
Python OOP 5 - Special (Magic/Dunder) Methods - https://youtu.be/3ohzBxoFHAY
Python OOP 6 - Property Decorators - https://youtu.be/jCzT9XFZ5bw
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Object-Oriented
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website - http://coreyms.com/
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Google Plus - https://plus.google.com/+CoreySchafer44/posts
Instagram - https://www.instagram.com/coreymschafer/
#Python

In this video I demonstrate how you can use magic functions, sometimes called dunder (double-underscore) functions, to support special list-like syntax in your own objects. Specifically, I will demonstrate __len__(), __contains__(), and __getitem__().

Code & Transcript : http://goo.gl/suIXKJ
Interactive Tutorial with Quiz Here : http://goo.gl/VKnCYb
Best Python Book : http://amzn.to/2aapV6S
Support me on Patreon : https://www.patreon.com/derekbanas
In this part of the tutorial I'll cover Inheritance, Operator Overloading, Polymorphism and Magic Methods, which are super awesome! If you missed previous parts of this tutorial watch those videos first.
Thank you to Patreon supports like the following for helping me make this video
https://www.facebook.com/cottageindustriesbuild/
@kyleaisho
@thetwistedhat
vjFaLk

Anjana Vakil - Using and abusing Python’s double-underscore methods and attributes
[EuroPython 2016]
[21 July 2016]
[Bilbao, Euskadi, Spain]
(https://ep2016.europython.eu//conference/talks/using-and-abusing-pythons-double-underscore-methods-and-attributes)
Python’s double-underscore ('`__`') methods and attributes go by many
names, including “special”, “dunder”, and “magic”. You already use
some, like `__init__`, but there are many more!
In this talk, we’ll see how dunders can be useful, silly, dangerous,
and fun! We’ll trick Python’s arithmetic and comparison operators.
We’ll make objects behave like dictionaries and containers. We’ll
reduce an object’s memory usage, and speed up membership tests. We’ll
even try some naughty function hacks!
-----
The curious Python methods and attributes surrounded by double
underscores ('`__`') go by many names, including “special”, “dunder”,
and “magic”. You probably use some of them, like `__init__`, every
day. But that’s just the tip of the iceberg!
In this talk, we’ll explore the weird and wonderful world of the
double-underscore, and find out how dunders can be useful, silly,
dangerous, and just fun! We’ll play pranks on Python’s builtin
operators for arithmetic and comparison. We’ll make arbitrary objects
behave like dictionaries and containers. We’ll reduce an object’s
memory usage, and speed up tests for membership. We’ll even try some
naughty function hacks that we should never use in real life!
You'll get the most out of this talk if you're already comfortable
writing object-oriented Python code. If you already use special dunder
magic in your own code, that's excellent! You’ll have a chance to
share your tips & tricks with the rest of the audience at the end of
the talk.
_Talk repo_: [https://github.com/vakila/dunders][1]
[1]: https://github.com/vakila/dunders

It's very simple to write straightforward imperative code with Python. You can easily define classes and functions, and write behavior inside them. However, pure imperative design means that you'll likely end up writing the same patterns of code over and over - whether it's requests.get() or LOGGER = getLogger(__name__). By taking advantage of some of the more advanced features of the Python language, like descriptors, overridden magic methods, and creative uses of inheritance, we can make our code smaller and more expressive. Proper abstractions will also make it easier to test your code thoroughly and effectively - because you're not reimplementing behavior unnecessarily, you can properly test the one place you do implement it, and rely on it from then on. And, it becomes much easier to add features later on that rely on existing behavior - you just need to describe them in terms of the things you've already implemented.
Presentation page -- https://2017.pycon.ca/schedule/23/

Everything in Python is an object and nothing is special. Python's built-in objects can be added, called, indexed, or with'd, and with a little magic, so can yours! Use of magic methods, those prefixed/suffixed with double underscores, can increase the flexibility of your code while also making it shorter and simpler.
Speaker: Nick Timkovich
Link: https://github.com/nicktimko/chipy-magicmethods
Founded in 2003, Chicago Python User Group is one of the world's most active programming language special interest groups with over 1,000 active members and many more prestigious alumni. Our main focus is the Python Programming Language.
Website: http://www.chipy.org/
Mentorship: https://chipymentor.org/
Slack: https://chipy.slack.com
Twitter: @ChicagoPython
Date: 2018-08-09
Location: Sully's House, Chicago

https://dbader.org/python-tricks ► Make those underscores count and write clean and beautiful Python, by example
Leading underscores in Python variable names (for example _foo and __foo) protect developers from naming conflicts. In this video you'll learn how to work with these Pythonic coding conventions and why they exist.
A single underscore in front of a variable name (prefix) is a hint that a variable is meant for internal use only.
A double underscore prefix causes the Python interpreter to rewrite the variable name in order to avoid naming conflicts in subclasses. Double underscores are also called "dunders" in Python.
Watch the video tutorial to see the details of how double underscore name mangling works and how it affects your own Python classes.
FREE COURSE – "5 Thoughts on Mastering Python" https://dbader.org/python-mastery
SUBSCRIBE TO THIS CHANNEL: https://dbader.org/youtube
* * *
► Python MUGS, T-SHIRTS & MORE: https://nerdlettering.com
FREE Python Tutorials & News:
» Python Tutorials: https://dbader.org
» Python News on Twitter: https://twitter.com/@dbader_org
» Weekly Tips for Pythonistas: https://dbader.org/newsletter
» Subscribe to this channel: https://dbader.org/youtube

https://dbader.org/python-tricks ► String conversion in Python classes and other advanced OOP techniques
When you define a custom class in Python and then try to print one of its instances to the console (or inspect it in an interpreter session) you get a relatively unsatisfying result. The default "to string" conversion behavior is basic and lacking in detail.
By default all you get is a string containing the class name and the `id` of the object instance (which is the object's memory address in CPython). That's better than *nothing*, but it's also not very useful.
The solution here is adding the `__str__` and `__repr__` "dunder" methods (some call them "magic methods") to your class.
They are the Pythonic way to control how objects are converted to strings in different situations.
In this tutorial video I'll do a deep dive on how Python's to-string conversion works and how you can add it to your own custom classes.
I'll walk you through the __str__ and __repr__ methods, when to use each, and some tips on how to use them in real world scenarios.
Just remember:
* The result of `__str__` should be readable.
* The result of `__repr__` should be unambiguous.
* Always add a `__repr__` to your classes. The default implementation for `__str__` just calls `__repr__`, so you get the best of both worlds.
To learn how to use the full potential of Python check out "Python Tricks: The Book" at the link below: https://dbader.org/pytricks-book
FREE COURSE – "5 Thoughts on Mastering Python" https://dbader.org/python-mastery
PYTHON TRICKS: THE BOOK https://dbader.org/pytricks-book
SUBSCRIBE TO THIS CHANNEL: https://dbader.org/youtube
* * *
► Python Developer MUGS, T-SHIRTS & MORE: https://nerdlettering.com
FREE Python Tutorials & News:
» Python Tutorials: https://dbader.org
» Python News on Twitter: https://twitter.com/@dbader_org
» Weekly Tips for Pythonistas: https://dbader.org/newsletter
» Subscribe to this channel: https://dbader.org/youtube

Welcome to part 19 of the intermediate Python programming tutorial series. In this tutorial, we are going to introduce the "special" or "magic" methods of Python, and, with that, talk about operator overloading, which is where we can define new ways for Python to handle operators like "+" in our example.
https://pythonprogramming.net
https://twitter.com/sentdex
https://www.facebook.com/pythonprogramming.net/
https://plus.google.com/+sentdex

Guys please help this channel to reach 20,000 subscribers. I'll keep uploading quality content for you.
Python is easy programming language to learn and anyone can learn it, and these tutorials are 100% free in hindi.
You can share this playlist with your brother, sisters and friends. This will surely add some values to their life.
Complete Playlist link - https://www.youtube.com/playlist?list=PLwgFb6VsUj_lQTpQKDtLXKXElQychT_2j
If you follow this complete playlist of python tutorial surely you will learn everything about python programming language.
This video is all about special magic/dunder methods, operator overloading, polymorphism.
Source Code Link - https://www.dropbox.com/s/c8vqlzxhx2ksp61/poly.py?dl=0

In this video, we will take a look at a common conditional statement in Python:
if __name__ == '__main__':
This conditional is used to check whether a python module is being run directly or being imported.
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website - http://coreyms.com/
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Google Plus - https://plus.google.com/+CoreySchafer44/posts
Instagram - https://www.instagram.com/coreymschafer/
#Python

In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python OOP 2 - Class Variables - https://youtu.be/BJ-VvGyQxho
Python OOP 3 - Classmethods and Staticmethods - https://youtu.be/rq8cL2XMM5M
Python OOP 4 - Inheritance - https://youtu.be/RSl87lqOXDE
Python OOP 5 - Special (Magic/Dunder) Methods - https://youtu.be/3ohzBxoFHAY
Python OOP 6 - Property Decorators - https://youtu.be/jCzT9XFZ5bw
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Object-Oriented
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website - http://coreyms.com/
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Google Plus - https://plus.google.com/+CoreySchafer44/posts
Instagram - https://www.instagram.com/coreymschafer/
#Python

In this Python Object-Oriented Tutorial, we will be learning about inheritance and how to create subclasses. Inheritance allows us to inherit attributes and methods from a parent class. This is useful because we can create subclasses and get all of the functionality of our parents class, and have the ability to overwrite or add completely new functionality without affecting the parents class in any ways. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python OOP 2 - Class Variables - https://youtu.be/BJ-VvGyQxho
Python OOP 3 - Classmethods and Staticmethods - https://youtu.be/rq8cL2XMM5M
Python OOP 4 - Inheritance - https://youtu.be/RSl87lqOXDE
Python OOP 5 - Special (Magic/Dunder) Methods - https://youtu.be/3ohzBxoFHAY
Python OOP 6 - Property Decorators - https://youtu.be/jCzT9XFZ5bw
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Object-Oriented
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website - http://coreyms.com/
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Google Plus - https://plus.google.com/+CoreySchafer44/posts
Instagram - https://www.instagram.com/coreymschafer/
#Python

Welcome to part 24 of the intermediate Python programming tutorial series. In this tutorial, we're going to cover two new special methods: __str__ and __repr__.
There are many different explanations about what __str__ and __repr__ are each used for. The main confusion, at least from what I can tell, is where and how __repr__ actually differs from __str__.
https://pythonprogramming.net
https://twitter.com/sentdex
https://www.facebook.com/pythonprogramming.net/
https://plus.google.com/+sentdex

Welcome to part 21 of the intermediate Python programming tutorial series. In this tutorial, we're going to take a unique opportunity to mesh OOP, iterables, iterators, special methods, AND generators.
https://pythonprogramming.net
https://twitter.com/sentdex
https://www.facebook.com/pythonprogramming.net/
https://plus.google.com/+sentdex

In this Python Object-Oriented Tutorial, we will be learning about classmethods and staticmethods. Class methods are methods that automatically take the class as the first argument. Class methods can also be used as alternative constructors. Static methods do not take the instance or the class as the first argument. They behave just like normal functions, yet they should have some logical connection to our class. We will look at some examples of both of these in order to understand both in depth. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python OOP 2 - Class Variables - https://youtu.be/BJ-VvGyQxho
Python OOP 3 - Classmethods and Staticmethods - https://youtu.be/rq8cL2XMM5M
Python OOP 4 - Inheritance - https://youtu.be/RSl87lqOXDE
Python OOP 5 - Special (Magic/Dunder) Methods - https://youtu.be/3ohzBxoFHAY
Python OOP 6 - Property Decorators - https://youtu.be/jCzT9XFZ5bw
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Object-Oriented
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website - http://coreyms.com/
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Google Plus - https://plus.google.com/+CoreySchafer44/posts
Instagram - https://www.instagram.com/coreymschafer/
#Python

In this Python tutorial, You can learn the easiest way to Python __init__ method or magic method, class & objects in Bangla or Bengali. Here, I will discuss what is Class, & objects then how to work Python magic or __init__ or constructor methods in details.

Petr Viktorin - The Magic of Attribute Access
[EuroPython 2014]
[22 July 2014]
Have you ever wondered how the "self" argument appears when you call a method? Did you know there is a general mechanism behind it? Come learn all about attributes and descriptors.
-----
The first part of this talk will describe what exactly happens when you
read or write an attribute in Python.
While this behavior is, of course, explained in the Python docs,
more precisely in the [Data model][1] section and [related][2] [writeups][3],
the documentation gives one a "bag of tools" and leaves combining them
to the reader.
This talk, on the other hand, will present one chunk of functionality,
the attribute lookup, and show how its mechanisms and customization
options work together to provide the flexibility (and gotchas) Python provides.
The topics covered will be:
* method resolution order, with a nod to the C3 algorithm
* instance-, class-, and metaclass-level variables
* `__dict__` and `__slots__`
* data/non-data descriptors
* special methods (`__getattr__`, `__getattribute__`, `__setattr__`, `__dir__`)
In the second part of the talk, I will show how to use the customization
primitives explained before on several interesting and/or useful examples:
* A proxy object using `__getattr__`
* Generic desciptor - an ORM column sketch
* the rudimentary `@property`, method, `staticmethod` reimplemented in
pure Python (explained [here][2] and elsewhere), which lead to
* SQLAlchemy's [`@hybrid_proprerty`][4]
* Pyramid's deceptively simple memoizing decorator, [`@reify`][5]
* An ["Unpacked" tuple properties][6] example to drive home the idea that
descriptors can do more than provide attribute access
(and mention weak dicts as a way to non-intrusively store data on an object)
(These are subject to change as I compose the talk. Also some examples may
end up interleaved with the theory.)
Hopefully I'll have time to conclude with a remark about how Python manages to be
a "simple language" despite having these relatively complex mechanisms.
[1]: http://docs.python.org/3/reference/datamodel.html
[2]: http://docs.python.org/3/howto/descriptor.html
[3]: https://www.python.org/download/releases/2.3/mro/
[4]: http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/hybrid.html
[5]: http://docs.pylonsproject.org/projects/pyramid/en/latest/api/decorator.html
[6]: https://gist.github.com/encukou/9789993

In this Python Object-Oriented Tutorial, we will be learning about the property decorator. The property decorator allows us to define Class methods that we can access like attributes. This allows us to implement getters, setters, and deleters. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python OOP 2 - Class Variables - https://youtu.be/BJ-VvGyQxho
Python OOP 3 - Classmethods and Staticmethods - https://youtu.be/rq8cL2XMM5M
Python OOP 4 - Inheritance - https://youtu.be/RSl87lqOXDE
Python OOP 5 - Special (Magic/Dunder) Methods - https://youtu.be/3ohzBxoFHAY
Python OOP 6 - Property Decorators - https://youtu.be/jCzT9XFZ5bw
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Object-Oriented
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website - http://coreyms.com/
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Google Plus - https://plus.google.com/+CoreySchafer44/posts
Instagram - https://www.instagram.com/coreymschafer/
#Python

This video is intended for use with the Introduction to Computer Science class at SSFS.
It is often helpful to print out information about an object. Python provides a special class method, __str__ that can help do this. In this video we look at how to implement this method.

In this Python Programming Tutorial, we will be looking at the Set data structure in-depth and discovering how it can help us solve some common problems. The set can not only solve certain problems more quickly but is also more efficient in many cases. Let's get started...
The code from this video can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Python/Python-Sets
If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:
https://www.patreon.com/coreyms
Or a one-time contribution through PayPal:
https://goo.gl/649HFY
If you would like to see additional ways in which you can support the channel, you can check out my support page:
http://coreyms.com/support/
Equipment I use and books I recommend:
https://www.amazon.com/shop/coreyschafer
You can find me on:
My website - http://coreyms.com/
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Google Plus - https://plus.google.com/+CoreySchafer44/posts
Instagram - https://www.instagram.com/coreymschafer/
#Python

Want access to all of our Python training videos? Visit our Learning Library, which features all of our training courses and tutorials at http://learn.infiniteskills.com?utm_source=youtube&utm_medium=youtube_video_description&utm_campaign=python_object_oriented_programming_classes_instances_attributes_methods&network=youtube
More details on this Python Beyond the Basics - Object-Oriented Programming training can be seen at http://www.infiniteskills.com/training/python-beyond-the-basics-object-oriented-programming.html?utm_source=youtube&utm_medium=youtube_video_description&utm_campaign=python_object_oriented_programming_classes_instances_attributes_methods&network=youtube This clip is one example from the complete course. For more free Python tutorials please visit our main website. YouTube: https://www.youtube.com/user/OreillyMedia
Facebook: https://www.facebook.com/OReilly/?fref=ts
Twitter: https://twitter.com/OReillyMedia
Website: http://www.oreilly.com/

In this video, we will learn the concepts of "Abstract Class" and "Abstract Method" in Python in detail.
Code can be found at
https://github.com/ashwin-pajankar/Python-OOP
The free e-book can be found at
https://leanpub.com/PythonOOP
Please let me know your valuable feedback on the video by means of comments. Please like and share the video. Do not forget to subscribe to my channel for more educational videos on Programming.
Please do visit my website
http://www.AshwinPajankar.com
I am on Google+ - http://plus.google.com/+AshwinPajankar
And twitter - @AshwinPajankar
Credits:
Music: http://www.bensound.com
Music: http://www.bensound.com/royalty-free-music

Child marriages are common:
On a recent day, eight community elders sat in a [refugee] camp, some chewing khat, the narcotic leaf favored by most Yemeni men. Seven have married off their girls this year.
Even Salim, the elder who worked at the charity, is preparing to marry off his two daughters, ages 13 and 14. "I want to feel secure of their futures, if only for economic reasons," he said.
Mohammad Ali al-Ansi married off his two girls, ages 13 and 14, in April. "My heart is bleeding inside, but I was forced to do this," he said. "I have no job. Its difficult for me to feed my 10 children." He received $1,600 in dowry for each of his girls, he said. But after paying for their weddings and meeting other debts, the money has nearly run out. "If things get worse, theres no doubt Ill marry off my 12-year-old daughter," Ansi said.

More on Ansis 14-year-old daughter Fatma, married to 21-year-old Zaid:
Fatma spent her day cooking and washing clothes for her in-laws. When asked the name of her husbands family, Fatma didnt know it. She remembers her father telling her and her sister, Amal, that the family needed money. She remembers that Amal was in tears because her new husband was taking her to another region. The two sisters have not seen each other since their weddings.
"I am too young to be married," Fatma said. "I want to study. I want to learn how to write. I have sacrificed for my family," she continued, her voice dropping to a whisper.
Minutes later, her husband arrived at the tent, and Fatma went silent. He said Fatma was "at a good age to marry." When asked if she could attend school, he shook his head no. "Shes a little too old for school," he said.
Female sexual freedom among the Tuareg : Flora Drury has written up the sex habits of the Saharas Muslim Tuareg people based on the work by Henrietta Butler. Some excerpts:
Their men became known as the blue men of the Sahara because the dye from their distinctive indigo scarves rub off onto their faces giving them a mysterious air. The Tuareg evoke images of a long forgotten and romantic age.