- Python OOP Tutorial 1: Classes and Instances

Python OOP Tutorial 1: Classes and Instances

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 a...
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


✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms

✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join

✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1

✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer

▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter -
Instagram - https://www.instagram.com/coreymschafer/

#Python

#Python #Classes #Object Oriented #OOP #Python Classes #Python Objects #Classes in Python #Python OOP #Class #Python Class #init #Python init #__init__ #Instance #Instances #Objects #Object Oriented Programming #Python Tutorial #Attributes #Methods
Introduction - Python OOP Tutorial 1: Classes and Instances

Introduction

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:00:00 - 00:00:33
Why use classes - Python OOP Tutorial 1: Classes and Instances

Why use classes

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:00:33 - 00:01:09
A simple class - Python OOP Tutorial 1: Classes and Instances

A simple class

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:01:09 - 00:02:13
Class vs Instance - Python OOP Tutorial 1: Classes and Instances

Class vs Instance

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:02:13 - 00:04:43
how come at , when he's assigning a variable emp_1.first  = "Corey" , he didn't get an error for using  "." in the variable name? we are not supposed to used anything except "_" while naming variables, aren't we? - Python OOP Tutorial 1: Classes and Instances

how come at , when he's assigning a variable emp_1.first = "Corey" , he didn't get an error for using "." in the variable name? we are not supposed to used anything except "_" while naming variables, aren't we?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:03:25 - 00:15:24
s]'' appear in the run window like it is in the video?[] - Python OOP Tutorial 1: Classes and Instances

s]'' appear in the run window like it is in the video?[]

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:18 - 00:15:24
In   how do you replace 1's with 2's? - Python OOP Tutorial 1: Classes and Instances

In how do you replace 1's with 2's?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:32 - 00:15:24
at  intentionally to make the subsequent point. Great work. Amazing video. Thanks :) - Python OOP Tutorial 1: Classes and Instances

at intentionally to make the subsequent point. Great work. Amazing video. Thanks :)

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:32 - 00:15:24
At  you changed a piece of multiple variable names at the same time, from 1 to 2. Could you tell me how did you do that? - Python OOP Tutorial 1: Classes and Instances

At you changed a piece of multiple variable names at the same time, from 1 to 2. Could you tell me how did you do that?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:33 - 00:15:24
Does anybody know how he made his text cursor larger to delete things from many lines at the same time? - Python OOP Tutorial 1: Classes and Instances

Does anybody know how he made his text cursor larger to delete things from many lines at the same time?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:33 - 00:15:24
He deliberately made the mistake at  to show us how powerful classes are. Genius move. A true coder. - Python OOP Tutorial 1: Classes and Instances

He deliberately made the mistake at to show us how powerful classes are. Genius move. A true coder.

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:33 - 00:15:24
has been done? thanks () - Python OOP Tutorial 1: Classes and Instances

has been done? thanks ()

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:33 - 00:15:24
if you wonder what's going on @  you can do it on your own with Ctrl + Alt + Arrow Keys - Python OOP Tutorial 1: Classes and Instances

if you wonder what's going on @ you can do it on your own with Ctrl + Alt + Arrow Keys

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:33 - 00:15:24
in a zippy at  ? - Python OOP Tutorial 1: Classes and Instances

in a zippy at ?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:33 - 00:15:24
Great tutorial, but quick question - what was the shortcut you used at ? - Python OOP Tutorial 1: Classes and Instances

Great tutorial, but quick question - what was the shortcut you used at ?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:35 - 00:15:24
What shortcut at  ? Is that specific to this code editor ?btw, nice video - Python OOP Tutorial 1: Classes and Instances

What shortcut at ? Is that specific to this code editor ?btw, nice video

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:35 - 00:15:24
thanks for the great explanation. Hope its not a dumb question,but how did you erase and type in multiple lines at the same time  ? - Python OOP Tutorial 1: Classes and Instances

thanks for the great explanation. Hope its not a dumb question,but how did you erase and type in multiple lines at the same time ?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:35 - 00:15:24
At  in the video you selected a column of 1s and changed them all to 2s, what IDE is that which allows for such nice efficiency? I wish I could do that in R Studio, where I code a lot and this would be a Godsend there. - Python OOP Tutorial 1: Classes and Instances

At in the video you selected a column of 1s and changed them all to 2s, what IDE is that which allows for such nice efficiency? I wish I could do that in R Studio, where I code a lot and this would be a Godsend there.

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:36 - 00:15:24
Hi, first of all, I would like to thank you for the helpful videos. then I have a question; in the  minute you have selected many letters at the same column and changed them at once. How can I do it!? ;-) - Python OOP Tutorial 1: Classes and Instances

Hi, first of all, I would like to thank you for the helpful videos. then I have a question; in the minute you have selected many letters at the same column and changed them at once. How can I do it!? ;-)

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:36 - 00:15:24
Initializing instance attributes with `__init__` - Python OOP Tutorial 1: Classes and Instances

Initializing instance attributes with `__init__`

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:04:43 - 00:09:00
Sorry if it’s a dumb question, but why do you use 2 - - of those for def init, but when you define other things, you don’t need the - - signs? - Python OOP Tutorial 1: Classes and Instances

Sorry if it’s a dumb question, but why do you use 2 - - of those for def init, but when you define other things, you don’t need the - - signs?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:05:22 - 00:15:24
MY whole existence has a meaning only because of - Python OOP Tutorial 1: Classes and Instances

MY whole existence has a meaning only because of

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:08:00 - 00:15:24
At  he gives THE BEST explanation of what SELF is. More than a week trying to figure out what self does. - Python OOP Tutorial 1: Classes and Instances

At he gives THE BEST explanation of what SELF is. More than a week trying to figure out what self does.

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:08:10 - 00:15:24
Hey! I hope you see my comment considering this is an old video. I have two questions. Around  on the video you have emp_1 and emp_2 outside def function, however they still work with the code inside “def __Init__”. I don’t understand why they still work. Why is that not necessary for your employe variables to be inside your Init function? - Python OOP Tutorial 1: Classes and Instances

Hey! I hope you see my comment considering this is an old video. I have two questions. Around on the video you have emp_1 and emp_2 outside def function, however they still work with the code inside “def __Init__”. I don’t understand why they still work. Why is that not necessary for your employe variables to be inside your Init function?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:08:30 - 00:15:24
Custom instance methods - Python OOP Tutorial 1: Classes and Instances

Custom instance methods

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:09:00 - 00:11:35
Hello Corey, Your tutorials are the best. I don't know if you still read and reply to comments but I have a question. Wouldn't it be easier in  to create another instance variable:(self.fullname = first + ' ' + last ) instead of a whole new function? - Python OOP Tutorial 1: Classes and Instances

Hello Corey, Your tutorials are the best. I don't know if you still read and reply to comments but I have a question. Wouldn't it be easier in to create another instance variable:(self.fullname = first + ' ' + last ) instead of a whole new function?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:09:53 - 00:15:24
on time  to ' return f"{self.first}, {self.last}" '  You can format it like that! - Python OOP Tutorial 1: Classes and Instances

on time to ' return f"{self.first}, {self.last}" ' You can format it like that!

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:10:46 - 00:15:24
which is a METHOD...watch from - Python OOP Tutorial 1: Classes and Instances

which is a METHOD...watch from

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:10:53 - 00:15:24
At    you print the emp_1 using  print(emp_1.fullname()).  I was able to print the same thing using print(Employee.fullname(emp_1)) otherwise i get an error. I'm using jupyter note book. Thanks and great stuff. - Python OOP Tutorial 1: Classes and Instances

At you print the emp_1 using print(emp_1.fullname()). I was able to print the same thing using print(Employee.fullname(emp_1)) otherwise i get an error. I'm using jupyter note book. Thanks and great stuff.

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:11:06 - 00:15:24
At  you can also make fullname an attribute similar to how you did with email except without "." and "@company.com". So what's the best practice out of the two in your example? - Python OOP Tutorial 1: Classes and Instances

At you can also make fullname an attribute similar to how you did with email except without "." and "@company.com". So what's the best practice out of the two in your example?

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:11:20 - 00:15:24
Common Mistake - Importance of passing `self` - Python OOP Tutorial 1: Classes and Instances

Common Mistake - Importance of passing `self`

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:11:35 - 00:14:25
Importance of passing `self` - Python OOP Tutorial 1: Classes and Instances

Importance of passing `self`

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:11:35 - 00:15:24
Minute  of the tutorial is bliss, finally getting what the 'self' keyword really does. Thank you for that great explanation! - Python OOP Tutorial 1: Classes and Instances

Minute of the tutorial is bliss, finally getting what the 'self' keyword really does. Thank you for that great explanation!

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:13:00 - 00:15:24
lmfao you literally explain how "self" works and how important it is. Perfect visualization. Thanks! - Python OOP Tutorial 1: Classes and Instances

lmfao you literally explain how "self" works and how important it is. Perfect visualization. Thanks!

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:13:55 - 00:15:24
Summary - Python OOP Tutorial 1: Classes and Instances

Summary

Python OOP Tutorial 1: Classes and Instances
2016年06月21日 
00:14:25 - 00:15:24

Corey Schafer

※本サイトに掲載されているチャンネル情報や動画情報はYouTube公式のAPIを使って取得・表示しています。

Timetable

動画タイムテーブル

動画数:237件

Lol probably simplest part of the video but how did you convert .env variables to uppercase so fast?? Something I struggle with for a lot of applications. - Automating My Bill Payments with Python and Selenium

Lol probably simplest part of the video but how did you convert .env variables to uppercase so fast?? Something I struggle with for a lot of applications.

Automating My Bill Payments with Python and Selenium
2024年06月02日  @trinityaikens6191 様 
00:17:09 - 01:18:30
Gave away the Util company there. Their address and pay to. - Automating My Bill Payments with Python and Selenium

Gave away the Util company there. Their address and pay to.

Automating My Bill Payments with Python and Selenium
2024年06月02日  @TheStevenWhiting 様 
00:21:24 - 01:18:30
how to override existing environment variables. (This is new to me) - Python Tutorial: Securely Manage Passwords and API Keys with DotEnv

how to override existing environment variables. (This is new to me)

Python Tutorial: Securely Manage Passwords and API Keys with DotEnv
2024年04月18日  @JorgeEscobarMX 様 
00:10:42 - 00:16:58
the future spoken is my current present. Unless I'm completely desperate, I'm not hitting reddit or google/stack overflow for most roadblocks. - How to Use ChatGPT as a Powerful Tool for Programming

the future spoken is my current present. Unless I'm completely desperate, I'm not hitting reddit or google/stack overflow for most roadblocks.

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  o k t o b e r 様 
00:12:22 - 00:31:08
Good video as always😉  I remember asking that too lol - How to Use ChatGPT as a Powerful Tool for Programming

Good video as always😉 I remember asking that too lol

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  kami 様 
00:28:19 - 00:31:08
@ - pure gold, pure gold! <3 - How to Use ChatGPT as a Powerful Tool for Programming

@ - pure gold, pure gold! <3

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  ulf gjerdingen 様 
00:28:26 - 00:31:08
You almost had me there haha! ChatGPT can be wrong but it certainly wasn't wrong about those top notch resources! I massively appreciate all the uploads and I hope they keep coming supercharged with Chat GPT. Thanks to you, sentdex, techwithtim and Dennis Ivy I now know how to properly code on python, use git for version control and build a functional website. - How to Use ChatGPT as a Powerful Tool for Programming

You almost had me there haha! ChatGPT can be wrong but it certainly wasn't wrong about those top notch resources! I massively appreciate all the uploads and I hope they keep coming supercharged with Chat GPT. Thanks to you, sentdex, techwithtim and Dennis Ivy I now know how to properly code on python, use git for version control and build a functional website.

How to Use ChatGPT as a Powerful Tool for Programming
2023年05月22日  Uj Vag 様 
00:28:42 - 00:31:08
and it's  am here (south east asia), and idk why I'm watching a python tutorial rather than sleeping 😂 - Python Tutorial: Simulate the Powerball Lottery Using Python

and it's am here (south east asia), and idk why I'm watching a python tutorial rather than sleeping 😂

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  X 様 
00:02:49 - 00:38:56
… nice… 😂 - Python Tutorial: Simulate the Powerball Lottery Using Python

… nice… 😂

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Bartosz Turkowyd 様 
00:04:50 - 00:38:56
I've seen every Python video you've made....   first innuendo. 😜 - Python Tutorial: Simulate the Powerball Lottery Using Python

I've seen every Python video you've made.... first innuendo. 😜

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Martin Beaudry 様 
00:04:52 - 00:38:56
Man it's  am in India I am lucky to be the first one to hear your voice god bless you brother and an awesome teacher. - Python Tutorial: Simulate the Powerball Lottery Using Python

Man it's am in India I am lucky to be the first one to hear your voice god bless you brother and an awesome teacher.

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Big Samosa 様 
00:12:15 - 00:38:56
# you can also use the built-in pprint module for pretty printing dictionaries ;) - Python Tutorial: Simulate the Powerball Lottery Using Python

# you can also use the built-in pprint module for pretty printing dictionaries ;)

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  Schoenling Wunderbar 様 
00:25:00 - 00:38:56
it would be very interesting to see if there could be a step function where this algorithm can simulate the increases in jackpot winnings. It’s going to be one in 292+ million of a chance that you hit it at all much less multiple times, but the code should be interesting to see. - Python Tutorial: Simulate the Powerball Lottery Using Python

it would be very interesting to see if there could be a step function where this algorithm can simulate the increases in jackpot winnings. It’s going to be one in 292+ million of a chance that you hit it at all much less multiple times, but the code should be interesting to see.

Python Tutorial: Simulate the Powerball Lottery Using Python
2023年01月10日  20 80 様 
00:27:43 - 00:38:56
A OAuth Django video would be awesome!(Applicable to all sorts of OAuth situations, not just the YouTube API.) - Python YouTube API Tutorial: Using OAuth to Access User Accounts

A OAuth Django video would be awesome!(Applicable to all sorts of OAuth situations, not just the YouTube API.)

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:07:58 - 00:43:21
At  you move the file and see some blurred miniature version of your open folders in the dock. How did you enable that? - Python YouTube API Tutorial: Using OAuth to Access User Accounts

At you move the file and see some blurred miniature version of your open folders in the dock. How did you enable that?

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:09:58 - 00:43:21
In case you are getting Error 403 ("access_denied The developer hasn’t given you access to this app") go to the OAuth consent screen and under Test Users add your email by clicking on Add Users.  You should be able to grant access after you've added User. - Python YouTube API Tutorial: Using OAuth to Access User Accounts

In case you are getting Error 403 ("access_denied The developer hasn’t given you access to this app") go to the OAuth consent screen and under Test Users add your email by clicking on Add Users. You should be able to grant access after you've added User.

Python YouTube API Tutorial: Using OAuth to Access User Accounts
2020年09月10日 
00:19:36 - 00:43:21
@corey  So why did you add the join function here, when appending the video id to the list its already a list and its working for me when I pass the vid_ids directly - Python YouTube API Tutorial: Calculating the Duration of a Playlist

@corey So why did you add the join function here, when appending the video id to the list its already a list and its working for me when I pass the vid_ids directly

Python YouTube API Tutorial: Calculating the Duration of a Playlist
2020年06月11日 
00:11:24 - 00:37:38
TypeError: expected string or bytes-like object, I am taking this error in , any idea? - Python YouTube API Tutorial: Calculating the Duration of a Playlist

TypeError: expected string or bytes-like object, I am taking this error in , any idea?

Python YouTube API Tutorial: Calculating the Duration of a Playlist
2020年06月11日 
00:18:50 - 00:37:38