Getting Started with Python and the Spyder 5 IDE (Object Orientated Programming OOP)

Channel:
Subscribers:
7,760
Published on ● Video Link: https://www.youtube.com/watch?v=-Njb5aOzU_g



Duration: 32:38
237 views
9


The Scientific Python Development Environment (Spyder) has a very similar user interface to the commercial product Matrix Laboratory (Matlab) which is commonly used to teach computer science fundamentals in Universities in the scientific and engineering fields. Unlike Matlab which is an expensive commercial product, Python and the Spyder Integrated Development Environment (IDE) are open-source and can be freely downloaded using the Anaconda Python Distribution. The Anaconda Python distribution contains a number of additional open source data science libraries such as Numeric Python (numpy), the Python and Data Analysis Library (pandas) and the Python plotting library (matplotlib) which can be used to replace Matlab functionality for most purposes in the scientific fields.

This particular video is a beginner guide that will look at importing objects from a user script file (or module) using the dot syntax. Although this video focuses on the concepts behind Object Orientated Programming mainly by working with modules, the analogy is extended to classes and then to modules and packages.

A slightly more detailed written guide is available here:
https://dellwindowsreinstallationguide.com/python-object-orientated-programming/

Note that this video continues on from my other tutorials on procedural programming and code blocks. You should understand these concepts before starting with this video. These videoss and guides are available here:

https://dellwindowsreinstallationguide.com/introduction-to-python-using-the-spyder-5-ide/
https://www.youtube.com/watch?v=JhlZnAYDRG0

https://dellwindowsreinstallationguide.com/introduction-to-python-code-blocks-with-builtin-python-using-the-spyder-5-ide/
https://www.youtube.com/watch?v=2mRBCNm8UUw

Modules can essentially be thought of as other python script files (.py extension). We can import objects from a module object_a by using:
from object_a import object_b
from object_a import object_b1, object_b2
from object_a import *

Alternatively we can import the object and use dot notation to reference objects within it:
import object_a
object_a.object_b
In the English language context, the dot can be thought of as a short hand abbreviation for get object_b from object_a.

Or import objects using an alias:
import object_a as alias
alias.object_b

We start by looking at only our own code. We can reference objects (functions and instances of inbuilt classes) from another module using the notation above. Instances of inbuilt classes (int, float, bool, str instances) can be directly reference. In the case of a function, we are only informed that it is a function when we reference it. In order to call a function, opposed to just referencing it, the function needs to be called with parenthesis which contain the functions input arguments. Details about these will be provided in the functions docstring.

Python has a huge number of inbuilt modules and additional modules available via an Anaconda installation. Many of these are used to routinely carry out additional functionality without writing everything from scratch. On a Windows 10 (default installation location), these can be found in:
%UserProfile%\anaconda3\Lib
I demonstrate using some of the inbuilt basic modules to highlight use of the dot syntax.

This dot notation is also used to reference attributes from within a class. attributes are objects i.e. instances of other classes and can be referenced directly. methods can be thought of as are functions contained within a class and like functions are referenced without parenthesis but called using parenthesis and any input argument. Once again details about these will be provided in the docstring.

More complicated Python code may be packaged. A Python Package is essentially a folder with multiple Python modules. The folder must contain an __init__.py module which is referenced when the folder alone is selected. Assuming we have a package folder1. Using dot notation to reference the folder:
import folder1
will reference the __init__ module within folder1. Other python scripts within the folder can be referenced using dot notation from the folder e.g. if there is a second file called test.py this can be accessed using:
import folder1.test
Python Packages are found as subfolders within:
%UserProfile%\anaconda3\Lib\site-packages

There are also a number of third party modules and packages available to download. I finish up by looking at the third-party package python-docx and explore how classes are being imported from the module using the dot notation and some of the nuances.

To install Anaconda for Windows and Linux see:
https://www.youtube.com/watch?v=0_3zF6Grwn4
https://www.youtube.com/watch?v=50Lp9tQw2cA
To update to Spyder 5 see:
https://www.youtube.com/watch?v=YO3xjM7Ct2w

#Python #programming #Spyder5




Other Videos By Philip Yip


2021-08-04Downloading a Windows 11 Insider Preview ISO, making a UEFI Bootable USB and Installation on a Dell
2021-07-15Install Ubuntu 20.04 LTS on Windows 11 Pro Hyper-V VM with UEFI BIOS and Secure Boot MOK Full Screen
2021-07-10Windows 11 Snap, Multi-Tasking and Multiple Monitors Feedback
2021-06-25Windows 11 Elevated System Requirements
2021-06-21Hexadecimal Colour Encoding Explanation using a Red, Green, Blue LED
2021-06-20A Clean Install of Zorin Linux 16 Beta (Dell UEFI BIOS with Secure Boot and MOK)
2021-06-18Python Object Orientated Programming (Spyder 5 IDE)
2021-06-13Python Code Blocks and Debugging (Spyder 5 IDE)
2021-06-10Python Procedural Programming (Spyder 5 IDE)
2021-05-26A Clean Install of KDE Neon Dell UEFI BIOS with Secure Boot
2021-05-23Getting Started with Python and the Spyder 5 IDE (Object Orientated Programming OOP)
2021-05-17A Clean Install of DeepIn Linux 20.2.2 Dell UEFI BIOS and Secure Boot
2021-05-16A Clean Install of Linux Mint 20.2 (Dell UEFI BIOS with Secure Boot and MOK)
2021-05-07Python: formatted strings (fstrings) and format specification for str, int and float objects
2021-03-121. Getting Started with Python and the JupyterLab 3 IDE. Object Orientated Programming (OOP)
2021-02-10Windows 10 Insider Preview New Emoji Panel, Clipboard History and Touchscreen Keyboard Feedback
2021-01-15DeepIn 20.1 Touchscreen Test on XPS 13 9365
2021-01-12XPS 13 Wacom Touchscreen Issues on Linux Mint 20.1
2021-01-02Windows 10 Environment Variables
2020-11-28Create Windows 10 (UEFI or Legacy BIOS) Bootable USB on Windows 10 (All Versions 15H1-21H2)
2020-11-18Dell Thunderbolt Dock Ubuntu 20.04 Boot Issue