The provided content is an article discussing the advanced concepts of Python programming, emphasizing the importance of understanding classes, data model functions, and the object-oriented nature of Python to become a proficient programmer.
Abstract
The article "Python Fundamentals To Become a True Programmer, Part 1" delves into the essential Python concepts that developers need to master to elevate their programming skills. It begins by acknowledging the simplicity of Python as a starting point and then progresses to more complex topics. The author emphasizes the significance of classes and their "dunder methods" for creating versatile objects. The article also introduces the idea that in Python, everything is an object, including functions, and illustrates how decorators can enhance functionality without altering the core function. The narrative concludes with a teaser for a follow-up article that promises to explore Python's features in greater depth.
Opinions
The author believes that understanding Python's features, rather than just knowing them, is key to becoming an expert.
There is an emphasis on the importance of data model functions, or "dunder methods," in allowing operations on objects.
The article suggests that Python's object-oriented nature is a powerful feature that should be leveraged, as demonstrated by the example of using decorators to add functionality to functions.
The author hints at the excitement and depth of Python yet to be explored in the upcoming articles, indicating a passion for the language and its capabilities.
There is a subtle endorsement of an AI service, ZAI.chat, as a cost-effective alternative to ChatGPT Plus, suggesting the author's belief in the value and performance of this service.
Python Fundamentals To Become a True Programmer, Part 1
The things you have to know — to improve your Python skills
Python has this charm to it. The crowds speak of it, almost romantically, how it is “just plain English.” It is so “simple and easy to understand” and the power of importing the fantastic modules of the open-source community — everything within your grasp.
Well, isn’t that true?
It is, no doubt about it, but that my friends is level 1.
Level 1 is the path each python developer goes through his way to become a real python developer, and I hope by the end of this article, to get you to a more advanced level and show you the needed path you must take.
This object you create will probably have attributes, and self operations, but python gives you much more, with the “dunder methods.”
The basics
Let us start with something simple — let’s say we need a class to represent a polynomial, it will probably look like this:
We want to have the ability to add or subtract them from another and even print them to the screen in a simple proper way, and here come the three most basic “dunder methods,” you add the appropriate methods, and you can use these operations!
If this looks completed because of the zip function, fear no more, the zip is just way to tie up two iterables, into a single iterable.
What most important for us to understand that SYNTAX DOES NOT MATTER, you realize that data model functions (“dunder methods”) allow you to operate on the object itself.
It is the crucial concept I’m putting out here, it’s starting simple, but it will get more interesting.
Level 3 — The World Is An Object
This saying is a common saying, since python 3, everything is an object, but what does this catch-phrase means?
Here is a typical example to illustrate the meaning of it. Let’s say we want to measure the time a function took to operate.
Now I’ve solved a local problem, what if I want to add it to 20 functions? This way is the wrong way, and it is not taking into account that everything in python is an object, including the function sub.
I can take sub-function and modify it, that calling sub will add a time check on the function.
Step 5 — the core concept, step 7, is in a syntax way.
There is no difference between step 5 and step 7. It is the same; this is called a decorator, the decorator lets the programmer addfunctionality to his functions, without touching the core function itself.
More data on “args,” “kwargs,” and more right here:
While this also hints the starting concept of article number 2 (and currently the last one planned).
The next article will dig deeper into the cores and features of the language, and hopefully give you a better understanding of what python is, more than just some fancy imports and stuff that looks like this:
I hope you enjoyed this article, I know I did, I wanted to squeeze in everything in one piece, but it felt too compact, I hope to see you in the next one, and I also hope this article gave you something new!
Here is something to read until part 2 of this post: