<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexandro Georgiev on Medium]]></title>
        <description><![CDATA[Stories by Alexandro Georgiev on Medium]]></description>
        <link>https://medium.com/@georgievalexandro?source=rss-f00d54402fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XtilPnbHn7LNnzwk</url>
            <title>Stories by Alexandro Georgiev on Medium</title>
            <link>https://medium.com/@georgievalexandro?source=rss-f00d54402fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:24:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@georgievalexandro/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Is Artificial Intelligence Dangerous? Understanding the Risks and Implications]]></title>
            <link>https://medium.com/@georgievalexandro/is-artificial-intelligence-dangerous-understanding-the-risks-and-implications-d788dfda1ed1?source=rss-f00d54402fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/d788dfda1ed1</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Alexandro Georgiev]]></dc:creator>
            <pubDate>Tue, 26 Dec 2023 11:00:20 GMT</pubDate>
            <atom:updated>2023-12-26T11:00:20.277Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*0QWkC3G7xLL96Qhw7rUIaQ.jpeg" /><figcaption>Image Source: FreeImages</figcaption></figure><p>Unless you’ve been living under a rock, you’ve probably heard of artificial intelligence (AI), especially in the last year or two. For many years, this topic has been a source of curiosity and worry. While advancements in AI have brought about numerous benefits and advancements in various industries, there is also a growing awareness of the potential risks and dangers associated with this technology. In this article, we will explore the risks of AI and its implications for society, as well as the steps we can take to mitigate these risks.</p><h4>Understanding Artificial Intelligence</h4><p>Before delving into the potential dangers, it is essential to have a clear understanding of what artificial intelligence is and how it functions. The development of computer systems that can do tasks that normally require human intelligence is referred to as artificial intelligence (AI). These activities might range from simple computations to complex problem-solving and decision-making procedures.</p><p>AI is classified into two types: applied AI and generalized AI. Applied AI refers to systems designed to perform specific tasks, such as facial recognition or internet searches. On the other hand, generalized AI aims to develop systems capable of handling any task that an intelligent human could perform.</p><h4>The Risks of Artificial Intelligence</h4><p>While we have not yet achieved super-intelligent machines, it is crucial to address the potential risks associated with AI in its current form. Here are some key risks and dangers to consider:</p><ol><li><strong>Autonomous Weapons</strong></li></ol><p>One of the most significant concerns surrounding AI is the development of autonomous weapons. These are AI-powered machines programmed to perform dangerous tasks, including the act of killing. The potential for a global autonomous weapons race is a real possibility, replacing traditional nuclear arms races. The risk lies in the possibility of these weapons gaining a “mind of their own” or falling into the wrong hands, leading to dire consequences.</p><p>2. <strong>Social Manipulation</strong></p><p>The power of AI algorithms in social media platforms has raised concerns about social manipulation. By analyzing vast amounts of data, AI algorithms can target individuals and spread information, whether factual or fictional, to influence their beliefs and behaviors. The Cambridge Analytica scandal, which involved the use of personal data from Facebook users to sway political outcomes, serves as a stark reminder of AI’s potential for social manipulation. You can read more details <a href="https://www.nytimes.com/2018/04/04/us/politics/cambridge-analytica-scandal-fallout.html">here</a>.</p><p>3.<strong> Invasion of Privacy and Social Grading</strong></p><p>The widespread use of AI surveillance systems raises significant concerns about invasion of privacy and social grading. With the ability to track and analyze individuals’ every move, AI-powered systems can gather personal data and make decisions that can impact people’s lives. China’s social credit system, which assigns citizens a personal score based on their behavior, serves as an example of how AI can be used for social oppression.</p><p>4. <strong>Misalignment between Goals</strong></p><p>When setting goals for AI machines, it is crucial to ensure alignment with human values. If the goals are not explicitly defined, machines may pursue their objectives, which may not align with human values. For example, a command to reach the airport as quickly as possible without specifying adherence to traffic rules could lead to dangerous consequences, prioritizing speed over safety.</p><p>5. <strong>Discrimination</strong></p><p>AI systems, with their ability to collect and analyze vast amounts of data, have the potential to discriminate against individuals. Insurance companies could deny coverage based on data collected through AI, while employers might make hiring decisions based on an individual’s “social credit score.” The misuse of AI technology can result in discrimination and the violation of individuals’ rights.</p><h4>Mitigating the Risks</h4><p>While the risks associated with AI are concerning, it is possible to mitigate them through careful planning and regulation. Here are some strategies to address the dangers of AI:</p><ol><li><strong>Ethical Frameworks and Regulations</strong></li></ol><p>Developing and implementing ethical frameworks and regulations is crucial to guide the development and deployment of AI systems. These frameworks should address issues such as privacy, fairness, transparency, and accountability. Governments, organizations, and researchers should collaborate to establish guidelines that ensure the responsible use of AI technology.</p><p>2. <strong>Bias Detection and Mitigation</strong></p><p>To prevent discriminatory outcomes, it is imperative to detect and mitigate biases in AI systems. This involves careful examination of training data and the algorithms used to ensure fairness and avoid reinforcing existing biases. Regular audits and assessments of AI systems can help identify and rectify any biases that may emerge.</p><p>3. <strong>Transparency and Explainability</strong></p><p>AI systems should be transparent and explainable to build trust and accountability. Users should have a clear understanding of how AI algorithms work and how they arrive at their decisions. This transparency allows for scrutiny and ensures that AI systems are not operating in a black box.</p><p>4. <strong>Human Oversight</strong></p><p>Maintaining human oversight over AI systems is important to prevent the misuse or unintended consequences of AI technology. Humans should be involved in the decision-making process and have the ability to intervene or override AI systems when necessary. This human-AI collaboration ensures that AI technology serves humanity’s best interests.</p><p>5. <strong>Continuous Monitoring and Evaluation</strong></p><p>Regular monitoring and evaluation of AI systems are essential to identify any potential risks or unintended consequences. Ongoing assessments can help detect issues early on and allow for necessary adjustments and updates to ensure the safe and responsible use of AI technology.</p><h4>Conclusion</h4><p>Artificial Intelligence holds great promise for improving our lives and advancing human society. However, it is crucial to recognize and address the potential risks and dangers associated with this technology. By implementing ethical frameworks, promoting transparency, and maintaining human oversight, we can harness the power of AI while minimizing its destructive potential. It is our collective responsibility to ensure the responsible development, deployment, and use of AI for the benefit of humanity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d788dfda1ed1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most popular AI Tools in 2023.]]></title>
            <link>https://medium.com/@georgievalexandro/monetizing-ai-tools-strategies-to-generate-income-with-ai-technology-f82eec8aa642?source=rss-f00d54402fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/f82eec8aa642</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Alexandro Georgiev]]></dc:creator>
            <pubDate>Mon, 25 Dec 2023 16:13:36 GMT</pubDate>
            <atom:updated>2023-12-25T17:05:26.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wQ0cZZQjN4SodHPg" /><figcaption>Photo by <a href="https://unsplash.com/@owenbeard?utm_source=medium&amp;utm_medium=referral">Owen Beard</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4><strong>Overview of AI Tools in 2023</strong></h4><p>The year 2023 has been a significant one for artificial intelligence (AI) breakthroughs. The rapid pace of development in AI has both amazed and concerned experts and the general public alike. Despite concerns, the popularity of AI tools has continued to rise. In a recent survey conducted by Writerbuddy.ai, an online content writing company, it was discovered that AI tools generated over 14 billion visits between September 2022 and August 2023. This article explores the top 10 AI tools of 2023 and how they can be used to generate more income.</p><h4><strong>Introduction to the Popularity of AI Tools</strong></h4><p>The increasing popularity of AI tools is evident as millions of users seek to harness the power of AI for various purposes. One of the most sought-after AI tools is ChatGPT, an AI chatbot that has garnered over 14.6 billion visits. Despite the negative press surrounding ChatGPT, including a recent leadership shakeup at OpenAI, the tool continues to be widely used. It can perform a wide range of tasks, from scheduling appointments to creating detailed resumes. Other AI tools like Character.ai and NovelAI serve as virtual companions, offering companionship and assistance to users.</p><h4><strong>Top 10 AI Tools of 2023</strong></h4><p>The top 10 AI tools of 2023, according to the rankings, are as follows:</p><ul><li><strong>ChatGPT</strong>: an AI chatbot that has amassed over 14.6 billion visits.</li><li><strong>Character.ai</strong>: an AI chatbot that provides virtual companionship.</li><li><strong>Quillbot</strong>: an AI writing tool that can summarize and paraphrase text.</li><li><strong>Midjourney</strong>: an image generator AI tool.</li><li><strong>Hugging Face</strong>: an AI tool used for data science purposes.</li><li><strong>Bard</strong>: a Google AI tool with capabilities similar to ChatGPT.</li><li><strong>NovelAI</strong>: an AI writing tool often used as a virtual companion.</li><li><strong>Capcut</strong>: a video generator AI tool.</li><li><strong>Janitor AI</strong>: an AI chatbot used for various purposes.</li><li><strong>Civitai</strong>: an image generator AI tool.</li></ul><ol><li><strong>ChatGPT</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*40i6ttZa_9-KbHYZ" /><figcaption>Photo by <a href="https://unsplash.com/@ilgmyzin?utm_source=medium&amp;utm_medium=referral">ilgmyzin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>ChatGPT is an AI chatbot that relies on natural language processing to create human-like conversational dialogue. The language model can answer questions and write many types of written content.</p><p>2. <strong>Character.ai</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VS4-kVTeqNb7HkAcDynWAw.jpeg" /><figcaption>Credit: Mashable composite: Character.ai</figcaption></figure><p>Character.AI is a website that employs a neural language model to scan large quantities of text and reply to requests using that information. Anyone can create a character on the site, and they can be fictional or based on real persons, dead or alive.</p><p>3. <strong>Quillbot</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjVgHwM-3XsQeFhsLE0dNQ.jpeg" /></figure><p>QuillBot is an advanced artificial intelligence (AI) writing tool, offers features such as sentence rephrasing, article rewriting and AI-generated content creation.</p><p>4. <strong>Midjourney</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J8cdP2i5dXLMqpenOme4Mg.jpeg" /></figure><p>Midjourney is a generative AI example that can translate natural language cues into images. It is only one of many machine learning-based picture generators that have recently developed. Despite this, it has risen to become one of the most well-known names in artificial intelligence, alongside DALL-E and Stable Diffusion.</p><p>5. <strong>Hugging Face</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*40Dn1-h4BXm1SdmY9dvLqA.jpeg" /><figcaption>Credits: Hugging Face</figcaption></figure><p>Hugging Face is an open source data science and machine learning platform. It acts as a hub for AI experts and enthusiasts — like a <a href="https://zapier.com/blog/what-is-github/">GitHub</a> for AI.</p><p>6. <strong>Bard</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dHYnS7FCz0VlGx-WxvWpRg.jpeg" /></figure><p>Google’s experimental conversational AI chat service, Bard. It is intended to function similarly to ChatGPT, with the main distinction being that Google’s service will obtain its data from the internet.</p><p>7. <strong>NovelAI</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*znAvVsL-iMKP5Ddm4zT7ig.jpeg" /></figure><p>NovelAI is a monthly subscription service for AI-assisted authorship, storytelling, virtual companionship, or simply a LLM powered sandbox for your imagination.</p><p>8. <strong>Capcut</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5RIg4jvpUyNtIugZTj0tgA.png" /></figure><p>Capcut is a desktop and web video editing tool. It’s a flexible tool with a plethora of AI functions and preloaded assets. And the best part is that it is completely free to use.</p><p>9. <strong>Janitor AI</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*xAXLp_GviOixEzcPDlGUkQ.png" /></figure><p>Similar to Character AI, Janitor AI allows you to create personas and have a chat with them.</p><p>10. <strong>Civitai</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*f_RCXWr5G1Hq5vF9UERTHw.jpeg" /></figure><p>CivitAI is a powerful art generation tool that uses Stable Diffusion to create art and images. The tool creates artwork in various styles and formats. It allows users to browse existing art pieces using its search engines. Users can also create art from scratch, edit it, and share it on other platforms.</p><p>These AI tools offer a wide range of functionalities and are responsible for attracting billions of visits, contributing to the AI revolution of 2023.</p><p>In conclusion, AI tools have gained immense popularity in 2023 due to their wide-ranging applications and benefits. From improving business processes to offering income-generating opportunities, AI technology has the potential to revolutionize various aspects of our lives. By embracing AI and leveraging its power, individuals and businesses can navigate the future with confidence and unlock new realms of success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f82eec8aa642" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Tips for Working with Python Classes Effectively]]></title>
            <link>https://medium.com/codex/10-tips-for-working-with-python-classes-effectively-153e6317631c?source=rss-f00d54402fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/153e6317631c</guid>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-class]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Alexandro Georgiev]]></dc:creator>
            <pubDate>Sun, 08 Jan 2023 12:46:55 GMT</pubDate>
            <atom:updated>2023-01-17T18:46:16.669Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*syM9IZwjuQJ34QrR" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The ability to encapsulate data and behavior in a structured, reusable manner is one of the primary advantages of using Python classes. Classes enable you to define the data that your program uses as well as the methods that operate on that data in a centralized location, making your code easier to understand and maintain. However, in order to ensure the effectiveness and efficiency of your classes, you must exercise caution when designing and enforcing them. Because poorly designed classes can result in confusing and error-prone code, it’s critical to remember a few key principles when working with Python classes. In this post, I’ll share ten tips for effectively working with Python classes.</p><h4><strong>1. Organize your class code properly</strong></h4><p>Organizing your code properly is probably one of the most important aspects of effectively working with Python classes and Python code in general. You will be able to understand and maintain your classes more easily if your code is organized and easy to read. And more importantly, people working with you will be able to understand your code. You need to understand that programmers are special creatures that don’t like inconveniences.</p><p>Here are a few pointers to help you do that:</p><ul><li><strong>Indentation and whitespace should be used appropriately</strong>: Proper indentation is critical for making your code easy to read and understand. It is generally recommended in Python to use <strong>four spaces</strong> for each level of indentation. Use blank lines to separate different sections of your code, making it easier to scan and read. You could go even further if you like, and use a code formatter like “<strong>black”</strong>.</li><li><strong>Keep related code blocks together</strong>: It can be beneficial to group related code blocks together when writing your class code. For example, at the top of your class, you might want to keep all of your class variables together, followed by your instance methods, and then any class-level or static methods. This will make it easier to locate and comprehend the various components of your class.</li></ul><pre>class MyClass:<br>    # Class variables<br>    x = 0<br>    y = 0<br>    <br>    # Instance methods<br>    def __init__(self, x, y):<br>        self.x = x<br>        self.y = y<br>        <br>    def show_values(self):<br>        print(f&quot;x: {self.x}, y: {self.y}&quot;)<br>        <br>    # Class-level or static methods<br>    @classmethod<br>    def set_x(cls, value):<br>        cls.x = value<br>        <br>    @staticmethod<br>    def add(a, b):<br>        return a + b</pre><p>At the top of the class are defined xand y, followed by the instance methods __init__and show_values, class level method set_xand static method add. This makes it easier to find and understand the various components of the class, and how they relate to each other.</p><p>A good practice would be to also comment the related block and help others and future self to understand what the block is doing.</p><p>Recommendations:</p><ul><li><a href="https://peps.python.org/pep-0008/">PEP 8 - Style Guide for Python Code | peps.python.org</a></li><li><a href="https://dev.to/j0nimost/setting-up-pep8-and-pylint-on-vs-code-34h">Setting Up PEP8 and Pylint on VS Code</a></li></ul><h4><strong>2. Give your classes and class variables descriptive names</strong></h4><p>Another important aspect of effectively working with Python classes is to give your classes and class variables descriptive and meaningful names. Would you like to enter an ongoing project and find code like this?</p><pre>class xyz:<br>    a = 0<br>    b = 0<br>    <br>    def __init__(self, a, b):<br>        self.a = a<br>        self.b = b<br>        <br>    def pqr(self):<br>        print(f&quot;a: {self.a}, b: {self.b}&quot;)</pre><p>Probably not! This example may be exaggerating a bit but it tries to prove a point.</p><p>By giving your classes and variables names that accurately reflect their purpose and function, you can make your code much easier to understand and maintain.</p><p>Here are some suggestions for good names:</p><ul><li><strong>Choose names that accurately reflect their function and purpose</strong>:</li></ul><pre>class Employee:<br>    first_name = &quot;&quot;<br>    last_name = &quot;&quot;<br>    salary = 0<br>    role = &quot;&quot;<br>    <br>    def __init__(self, first_name, last_name, salary, role):<br>        self.first_name = first_name<br>        self.last_name = last_name<br>        self.salary = salary<br>        self.role = role<br>        <br>    def display_employee_info(self):<br>        print(f&quot;Name: {self.first_name} {self.last_name}, Salary: {self.salary}, Role: {self.role}&quot;)</pre><ul><li><strong>Avoid abbreviations and acronyms</strong>:</li></ul><pre>class Emp:<br>    fn = &quot;&quot;<br>    ln = &quot;&quot;<br>    sal = 0<br>    rl = &quot;&quot;<br>    <br>    def __init__(self, fn, ln, sal, rl):<br>        self.fn = fn<br>        self.ln = ln<br>        self.sal = sal<br>        self.rl = rl<br>        <br>    def dsp_emp_inf(self):<br>        print(f&quot;Name: {self.fn} {self.ln}, Salary: {self.sal}, Role: {self.rl}&quot;)</pre><p><strong>Please don&#39;t! </strong>You are not saving the planet by keeping a few letters to yourself :)</p><h4><strong>3. Choose the appropriate visibility for your class variables</strong></h4><p>Consider the visibility of your class variables when working with python classes. There are three levels of visibility in Python: <strong>public</strong>, <strong>protected</strong>, and <strong>private</strong>. I will also explain why this is not entirely true.</p><pre>class MyClass:<br>    def __init__(self):<br>        # Variables with single underscore prefix are considered <br>        # protected and should be used with caution<br>        self._protected_var = 0<br>        # Variables without prefix are considered public and can be <br>        # accessed freely<br>        self.public_var = 0<br>        # Variables with double underscore prefix are considered private <br>        # and should not be accessed from outside the class<br>        self.__private_var = 0<br>    <br>    # Methods with single underscore prefix are considered protected <br>    # and should be used with caution<br>    def _protected_method(self):<br>        print(&quot;This is a protected method.&quot;)<br>        <br>    # Methods with double underscore prefix are considered private <br>    # and should not be accessed from outside the class<br>    def __private_method(self):<br>        print(&quot;This is a private method.&quot;)<br>        <br>    # Methods without prefix are considered public and can be accessed freely<br>    def public_method(self):<br>        print(&quot;This is a public method.&quot;)</pre><p><em>Keep in mind that this is not entirely correct because, unlike C++, Python does not have private variables or methods in the same sense. Python uses the “_” and “__” characters to mangle variable names, making them difficult to access from outside. However, someone with enough determination will still be able to access all of a class’s variables and methods. Python community is more about trust and acting like adults.</em></p><h4>4. Use inheritance to reduce code duplication.</h4><p>Inheritance is one of the four core principles of object-oriented programming, and is a powerful feature that allows you to create hierarchies in which one class (referred to as the <strong>subclass</strong>) inherits properties of a <strong>superclass. </strong>Inheritance is effective in reducing code duplication and encouraging code reuse. The other three principles are: <strong>abstraction</strong>, <strong>encapsulation</strong>, <strong>polymorphism</strong>. These are the four words that should immediately come to your mind when you hear <strong>object-oriented programming</strong>.</p><p>Here are a few pointers for making the most of your inheritance:</p><ul><li><strong>Use inheritance to share code between related classes</strong></li><li><strong>Learn how to use inheritance to build a class hierarchy</strong>:</li></ul><pre>class Shape:<br>    def __init__(self):<br>        self.name = &quot;&quot;<br>        <br>    def get_name(self):<br>        return self.name<br><br>class Circle(Shape):<br>    def __init__(self, radius):<br>        super().__init__()<br>        self.name = &quot;Circle&quot;<br>        self.radius = radius<br>        <br>    def get_area(self):<br>        return 3.14 * (self.radius ** 2)<br><br>class Square(Shape):<br>    def __init__(self, side):<br>        super().__init__()<br>        self.name = &quot;Square&quot;<br>        self.side = side<br>        <br>    def get_area(self):<br>        return self.side ** 2<br><br>c = Circle(5)<br>print(c.get_name()) # Output: Circle<br>print(c.get_area()) # Output: 78.5<br><br>s = Square(10)<br>print(s.get_name()) # Output: Square<br>print(s.get_area()) # Output: 100</pre><p>Here is my favourite Shapeclass that every student has seen a million times. This is the equivalent of “Hell…”, “Hello W…”, “Hello World!”.</p><p>Shape class in the above example contains a name attribute and a get_name method.</p><p>Circle and Squareinherit from the Shape class. The Circle class has an additional attribute radiusand a method get_areathat calculates the area. The Square class has an additional attribute sideand a method get_areathat calculates the area of a square.</p><p>They both have the name attribute inherited from their parent class and they also have their own specific attributes and methods.</p><p>As already mentioned, inheritance is effective in reducing code duplication and encouraging code reuse. This way — code is more structured and easier to maintain.</p><h4>5. Override class methods and operators carefully</h4><p>Python allows us to override class methods and operator in a subclass, which can be a useful tool for customising your classes’ behavior and making them more suitable to specific needs.</p><p>If not done correctly, however, it can result in unexpected or unintended behaviour. You should pay attention when doing this.</p><p>Here are a few pointers for safely overriding methods and operators:</p><ul><li><strong>Understand how to override methods in a base class in a subclass</strong>: If you decided to override a method in a subclass, first try to understand how the method is used in the base class as well as the changes you wish to apply. Read the documentation and test your changes to make sure they work as intended.</li><li><strong>Overriding built-in operators should be done with caution</strong>:</li></ul><pre>class MyNumber:<br>    def __init__(self, value):<br>        self.value = value<br><br>    def __add__(self, other):<br>        return MyNumber(self.value + other.value)<br><br>    def __str__(self):<br>        return str(self.value)<br><br>a = MyNumber(5)<br>b = MyNumber(10)<br><br>c = a + b<br>print(c) # Output: 15</pre><p>In the example above, the MyNumberclass has a valueattribute and overrides the __add__and __str__methods. The __add__method is used to override the built-in +operator, allowing instances of the MyNumberclass to be added together. Overriding the built-in str()method via __str__allows instances of the class to be printed.</p><p>As showed in the example, when instances of the class are added together, the __add__method is called and the valueattribute of each instance is added together, then it returns a new instance of MyNumberclass with the result.</p><p>Here’s an example of <strong>bad</strong> overriding causing side effects.</p><pre>class MyList:<br>    def __init__(self, values):<br>        self.values = values<br><br>    def __add__(self, other):<br>        # This method is modifying the original instance instead of <br>        # returning a new instance<br>        self.values.extend(other.values)<br>        return self<br><br>a = MyList([1, 2, 3])<br>b = MyList([4, 5, 6])<br><br># c is pointing to the same instance as a, <br># so it will contain the modified values<br>c = a + b<br>print(c.values) # Output: [1, 2, 3, 4, 5, 6]<br>print(a.values) # Output: [1, 2, 3, 4, 5, 6]</pre><p>Be careful when doing such kind of implementations, as they can lead to unexpected behaviour and side effects!</p><h4>6. Implement the “magic methods” to customize class behavior</h4><p>Methods known as “magic methods” or “dunder methods” are a set of special methods in Python. <strong>“Dunder”</strong> is a shortcut for <strong>“double underscore before and after.”</strong> These methods are denoted by double underscores (e.g. “<strong>init</strong>”, “<strong>str</strong>”, “<strong>add</strong>”, etc.) and are used to define special behavior for your classes.</p><p>Here are a couple of tips for using magic methods effectively:</p><ul><li><strong>Learn about the magic methods and when to use them</strong></li><li><strong>Implement these methods to add custom behavior to your classes</strong>: By implementing magic methods in your classes, you can add custom behavior that is tailored to your specific needs. For example, you might use the “<strong>add</strong>” method to define how two instances of a class should be added together, or you might use the “<strong>getitem</strong>” method to define how to access elements of an instance using the indexing operator (e.g. instance[i]).</li></ul><p>You can refer to previous code examples and see how some of those methods are implemented.</p><h4>7. Use @property and @&lt;prop&gt;.setter to define getters and setters</h4><p>In Python, it is possible to use the @property and @&lt;prop&gt;.setter decorators to define getters and setters for class attributes. Getters and setters are methods that allow you to control access to and modification of class attributes, and can be a useful tool for ensuring the integrity of your class’s data.</p><p>Here are a couple of tips for using getters and setters effectively:</p><ul><li><strong>Understand how to use the @property and @&lt;prop&gt;.setter decorators</strong></li><li><strong>Use getters and setters to control access to class data and ensure proper validation</strong></li></ul><pre>class MyClass:<br>    def __init__(self):<br>        # using single underscore prefix to indicate that <br>        # the attribute should not be accessed directly<br>        self._attr = 0<br>    <br>    # Using property decorator to define getter method<br>    @property<br>    def attr(self):<br>        return self._attr<br>    <br>    # Using setter decorator to define setter method<br>    @attr.setter<br>    def attr(self, value):<br>        self._attr = value</pre><p>By using property decorator, the attribute can be accessed like a normal attribute but the getter and setter methods will be called internally. This way, we can add some validation or logging code inside the getter and setter methods and make the class more robust.</p><h4>8. Use @classmethod and @staticmethod to define class-level and static methods</h4><p>Python allows us to use the @classmethodand staticmethoddecorators to define class-level and static methods in your classes. Class-level methods are bound to the class instead of instances of the class, while static methods are methods that do not depend on any class or instance.</p><p>Here are a couple of tips for using class-level and static methods effectively:</p><ul><li><strong>Understand the difference between these types of methods and when to use them</strong></li><li><strong>Use class-level and static methods to add functionality to your class that does not depend on instance data</strong></li></ul><pre>class MyClass:<br>    # class variable, accessible from class level methods<br>    class_var = &quot;class variable&quot;<br><br>    def __init__(self, var):<br>        # instance variable, accessible from instance methods<br>        self.var = var<br><br>    @classmethod<br>    def class_level_method(cls):<br>        &quot;&quot;&quot;<br>        Class level method, it can access class level variable <br>        and modify them<br>        &quot;&quot;&quot;<br>        return cls.class_var<br><br>    @staticmethod<br>    def static_method(x, y):<br>        &quot;&quot;&quot;<br>        Static method, it does not depend on any class or instance data<br>        &quot;&quot;&quot;<br>        return x + y<br><br># Using class-level method<br>print(MyClass.class_level_method()) # Output: class variable<br><br># Using static method<br>print(MyClass.static_method(5, 10)) # Output: 15<br><br># Creating an instance of the class<br>obj = MyClass(10)<br>print(obj.var) # Output: 10</pre><h4>9. Document your classes and methods</h4><p>Documentation is an important aspect of software development, and this is especially true when working with classes in Python. By documenting your classes and methods, you can make it easier for others (or your future self) to understand and use your code.</p><p>Here are a couple of tips for documenting your classes and methods effectively:</p><ul><li><strong>Use docstrings to document your classes and methods</strong>: Python supports a special type of string called a docstring that is used to document classes and methods. Docstrings are placed at the beginning of a class or method definition and are typically surrounded by triple quotes (“””). For example:</li></ul><pre>class MyClass:<br>    &quot;&quot;&quot;This is the docstring for MyClass. It provides a brief<br>    description of the class and its purpose.<br>    &quot;&quot;&quot;<br>    def __init__(self):<br>        &quot;&quot;&quot;This is the docstring for the __init__ method. It<br>        explains what the method does and how it is used.<br>        &quot;&quot;&quot;<br>        pass</pre><ul><li><strong>Include information about the parameters, return value, and any side effects of your methods</strong>: When documenting your methods, it is helpful to include information about the parameters that the method takes, the return value of the method, and any side effects that the method might have (e.g. modifying class data). This will make it easier for others to understand how to use your methods and what to expect when calling them.</li></ul><h4>10. Write unit tests to ensure your classes are working correctly</h4><p>I would recommend getting yourself familiar with <strong>TDD (Test-driven development). </strong>This means you will begin by first write your test cases and then implement your classes. Explaining TDD is beyond the scope of this article but I strongly advise you to learn it.</p><p>Here’s a simple test example using unittest library.</p><pre>import unittest<br><br>def add_numbers(a, b):<br>    return a + b<br><br>def subtract_numbers(a, b):<br>    return a - b<br><br>class TestMyFunctions(unittest.TestCase):<br>    def test_addition(self):<br>        result = add_numbers(2, 2)<br>        self.assertEqual(result, 4)<br><br>    def test_subtraction(self):<br>        result = subtract_numbers(5, 2)<br>        self.assertEqual(result, 3)<br><br>if __name__ == &#39;__main__&#39;:<br>    unittest.main()</pre><p>This is just an example. In a real project you would probably separate tests and rest of the code in separate files and modules.</p><p>How to run the test?</p><pre>python -m unittest script_name</pre><p>Conclusion:</p><p>In this article, we have covered 10 tips for effective Python class development. By following these tips, you can make your classes more powerful, flexible, and easy to understand and maintain.</p><p>Here is a brief recap of the tips we covered:</p><ol><li>Organize your class code properly</li><li>Give your classes and class variables descriptive names</li><li>Choose the appropriate visibility for your class variables</li><li>Use inheritance to reduce code duplication</li><li>Override class methods and operators carefully</li><li>Implement the “magic methods” to customize class behavior</li><li>Use @property and @&lt;prop&gt;.setter to define getters and setters</li><li>Use @classmethod and @staticmethod to define class-level and static methods</li><li>Document your classes and methods</li><li>Write unit tests to ensure your classes are working correctly</li></ol><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=153e6317631c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/10-tips-for-working-with-python-classes-effectively-153e6317631c">10 Tips for Working with Python Classes Effectively</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python pathlib — an alternative to the OS module]]></title>
            <link>https://medium.com/codex/python-pathlib-an-alternative-to-the-os-module-3dcde93bf7df?source=rss-f00d54402fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dcde93bf7df</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[filesystem]]></category>
            <category><![CDATA[path]]></category>
            <dc:creator><![CDATA[Alexandro Georgiev]]></dc:creator>
            <pubDate>Sun, 03 Jul 2022 18:44:41 GMT</pubDate>
            <atom:updated>2022-07-05T13:42:22.549Z</atom:updated>
            <content:encoded><![CDATA[<h3>Python pathlib — an alternative to the OS module</h3><p>As a bit of a programmer myself, I frequently work with paths as part of my job. And since you’re here, I suppose you are as well. In this article, I’ll seek to convince you to use pathlib.</p><p><em>I’d like to point out that this article is geared more toward beginning programmers or those who are just getting started with Python and handling file paths. Everyone, however, is welcome to read it and learn something new or recall something forgotten.</em></p><p>Ok…let’s get to the good stuff.</p><h3>What is pathlib and why would you use it?</h3><p>To answer the first question — the official documentation states:</p><blockquote>This module offers classes representing filesystem paths with semantics appropriate for different operating systems. Path classes are divided between pure paths, which provide purely computational operations without I/O, and concrete paths, which inherit from pure paths but also provide I/O operations.</blockquote><p>In other words, <strong>Pure Path</strong> and <strong>Concrete Path</strong> are the two classes that represent the two different sorts of path objects that pathlib separates the filesystem paths into.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/0*VBSsRUcykv6IM8tT.png" /></figure><ul><li><strong>Pure</strong>: <em>PurePath</em>, <em>PurePosixPath</em>, <em>PureWindowsPath</em></li><li><strong>Concrete</strong>: <em>Path, PosixPath, WindowsPath</em></li></ul><p>While the concrete path allows you to control and perform writing operations on your file path, the pure path offers tools to manage and manipulate your file path without doing so.</p><p>Or to put it another way, a Pure path is a subclass of a Concrete path. It adds input/output operations that make system calls and inherits manipulation from the parent class.</p><p>Now for the second question: <em>why </em>would you use it?</p><p>In my opinion, <strong>the </strong>pathlib<strong>module improves the maintainability and simplicity of the code by being more straightforward and practical than the </strong>os.path<strong>module’s approach.</strong> However, this will be discussed<strong> </strong>in more detail in the following examples.</p><p>Let’s see an example:</p><p><strong>Note!</strong> We need Python version ≥ 3.4 to use Pathlib.</p><p>Let’s say we have <strong>N</strong> files that needs to be moved to a specific folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFESxqVeCCt09CmZgIYxGg.png" /><figcaption>CentOS Linux | Python 3.6 | Example 1</figcaption></figure><p>First thing we notice is that we need three imports just to move those file to another folder. If trash directory happens to already exist then a FileExistsError is raised.</p><p>The same example but using pathlib</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YnVl2NxYWBS_4ZwBWcqaPA.png" /><figcaption>CentOS Linux | Python 3.6 | Example 1</figcaption></figure><p>Path.replace(<em>target</em>) will rename the file to the given destination, and return a new Path instance pointing to the target. parents=True will make sure that any missing parents of this path are created as needed. If exist_okis true, FileExistsError exceptions will be ignored.</p><p>What can we use pathlib for in practice?</p><h3><strong>Creating paths</strong></h3><p>Despite being introduced to various flavors of the module, chances are you will only need the pathlib.Pathclass. There are a few different ways of creating a path.</p><ul><li>We could use for example .cwd() and .home() methods that the module offers us.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdI4WXvoA5X_3ix42Cn6Sg.png" /></figure><ul><li>Use the special operator /</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e1p6IPG1rqzguAFvSNi7eA.png" /></figure><ul><li>Create explicitly from a string representation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ad1A0vmR3BvuvI2ghgMfJQ.png" /></figure><h3>Reading, Writing, Moving and Deleting Files</h3><ul><li>.read_text(<em>encoding=None, errors=None</em>) : return the decoded contents of the pointed-to file as a string</li><li>.read_bytes() : return the binary contents of the pointed-to file as a bytes object</li><li>.write_text(<em>data, encoding=None, errors=None, newline=None</em>) : open the file pointed to in text mode, write <em>data</em> to it, and close the file. An existing file of the same name is overwritten.</li><li>.write_bytes(<em>data</em>) : open the file pointed to in bytes mode, write <em>data</em> to it, and close the file. An existing file of the same name is overwritten.</li><li>.replace(<em>target</em>) : rename this file or directory to the given <em>target</em>, and return a new Path instance pointing to <em>target</em>. If <em>target</em> points to an existing file or empty directory, it will be unconditionally replaced.</li><li>.rename(<em>target</em>) : rename this file or directory to the given <em>target</em>, and return a new Path instance pointing to <em>target</em>. On Unix, if <em>target</em> exists and is a file, it will be replaced silently if the user has permission. On Windows, if <em>target</em> exists, FileExistsError will be raised. <em>target</em> can be either a string or another path object.</li><li>.unlink(<em>missing_ok=False</em>) : remove file or symbolic link.</li><li>.rmdir() : remove directory</li></ul><p>What makes reading and writing methods so convenient to use is the fact that they handle the opening and closing of the file.</p><p>Examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*it64smlBtApkSVlNUTf0DA.png" /></figure><h3>Useful methods and properties</h3><p>This is a short list of the most used properties</p><ul><li>.name : the file name without any directory</li><li>.suffix : the file extension of the final component, if any</li><li>.stem : the file name without the suffix</li><li>.parent : the logical parent of the path</li><li>.anchor : the concatenation of the drive and root</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eusj26eiTRRg1yzAAG_2MA.png" /></figure><p>This is a short list of the most used methods</p><ul><li>.exists() : return True if file exists and False otherwise</li><li>.is_dir() : check if path is a directory</li><li>.is_file() : check if path is a file</li><li>.expanduser() : return a new path with expanded ~ and ~user constructs</li><li>.glob() : glob the given relative <em>pattern</em> in the directory represented by this path, yielding all matching files</li><li>.iterdir() : yield path objects of the directory contents</li><li>.mkdir() : create a new directory at this given path</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ean4J3UoZdcmNsiPTo7OCA.png" /></figure><h3>Some practical examples</h3><ul><li>Collecting filenames — this could potentially be something you have to do</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XGet8psFa2XHAfy0Zz4Kw.png" /></figure><ul><li>Move files to a specific directory — this one you have already seen on the beginning</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YnVl2NxYWBS_4ZwBWcqaPA.png" /></figure><h3>Conclusion</h3><p>File paths are represented by objects in pathlib which makes work with them much easier. We have control over all components of the object and it’s really easy to extract exactly what we need from it. As I already mentioned, pathlib module is simpler and more convenient to use.</p><h3>Last words</h3><p>Don’t get me wrong: I’m not against the osmodule. Pathlib is more of a personal preference. os will do the same job flawlessly. I am an active learner, and writing articles helps me better understand things. My hope is that the articles will be useful to others. Feel free to leave corrections in the comments section, and I’ll do my best to include them.</p><p>Thank you for reading!</p><h3>References</h3><ul><li><a href="https://realpython.com/python-pathlib/">Python 3&#39;s pathlib Module: Taming the File System - Real Python</a></li><li><a href="https://docs.python.org/3/library/pathlib.html#pathlib.Path.write_bytes">pathlib - Object-oriented filesystem paths - Python 3.10.5 documentation</a></li><li><a href="https://www.freecodecamp.org/news/how-to-use-pathlib-module-in-python/">Python Path - How to Use the Pathlib Module with Examples</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dcde93bf7df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/python-pathlib-an-alternative-to-the-os-module-3dcde93bf7df">Python pathlib — an alternative to the OS module</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 things to make you a superior Python developer in 2023]]></title>
            <link>https://medium.com/codex/3-things-to-make-you-a-superior-python-developer-in-2022-3a5ccd4a4ee1?source=rss-f00d54402fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a5ccd4a4ee1</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[softare-development]]></category>
            <dc:creator><![CDATA[Alexandro Georgiev]]></dc:creator>
            <pubDate>Sun, 19 Jun 2022 18:11:46 GMT</pubDate>
            <atom:updated>2023-01-17T12:05:40.759Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<p>Python is undoubtedly one of the most extensively used programming languages in the world, frequently competing for first place with popular high-level languages such as C#, JavaScript, and Java. Many elements of Python have stayed unaltered since its commencement, yet as time passes, and each new version of Python, along come better approaches for getting things done and new libraries that exploit those advances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LAJ--jcfL1FrKRtq" /><figcaption>Photo by <a href="https://unsplash.com/@feneek?utm_source=medium&amp;utm_medium=referral">Sergey Semin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You want to compete with the best in the industry? Here are three things you should take advantage of.</p><h3>Virtual environments and package management</h3><p>External libraries are heavily used by Python developers to provide functionality and fix bugs. Various versions of each tool will be required depending on the complexity of the problem at hand. It can be difficult to use any tool to solve an issue while another project you’re working on requires an older version of the framework due to its dependencies. This is a typical issue that virtual environments may help with.</p><p>For simple projects you can just use Python’s built-in <a href="https://docs.python.org/3/library/venv.html"><strong><em>venv</em></strong></a><strong><em> </em></strong>to keep projects and their requirements in a separate environment. But recently added tools in Python gives you more options:</p><ul><li><a href="https://github.com/pyenv/pyenv"><strong>Pyenv</strong></a><strong>: </strong>Managing various Python versions with <strong>pyenv </strong>is a breeze. Even if you already have Python installed on your PC, pyenv is useful for quickly trying out new language features or contributing to a project that uses a different version of Python. Because there is no official support for Windows, <a href="https://github.com/pyenv-win/pyenv-win"><strong>pyenv-win</strong></a> with basic support has recently become active.</li><li><a href="https://pipenv.pypa.io/en/latest/"><strong>Pipenv</strong></a>: Pipenv is designed to manage a virtual environment as well as all of your project’s dependencies. It also ensures that dependencies are deterministic — that you get the versions you want and that they work in the combinations you specify.</li><li><a href="https://docs.conda.io/en/latest/"><strong>Conda</strong></a>: Anaconda is a deployment package management library. It also includes plenty of scientific Python libraries for machine learning, artificial intelligence, and big data. Anaconda includes a package and environment manager known as <strong>conda</strong>, which is defined in the official documentation as — <em>Package, dependency and environment management for any language — Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++, Fortran, and more.</em></li><li><a href="https://python-poetry.org/"><strong>Poetry</strong></a>: When you use external packages in your Python project, you must ensure that you are using the correct version of each package. A package may no longer function as it did prior to the update. A dependency manager, such as Python Poetry, assists you in specifying, installing, and resolving external packages in your projects. This way, you can be certain that you are always working with the correct dependency version on each machine.</li><li><a href="https://pdm.fming.dev/latest/"><strong>PDM</strong></a>: PDM or Python Development Master is meant to be a next generation Python package management tool. Stick using <strong>Pipenv </strong>or <strong>Poetry </strong>if you’re happy with them and don’t want to switch to another package manager. However, if you’re looking for something that isn’t available in those tools, you’ll most likely find it in <strong>pdm</strong>.</li></ul><h3>New Python features</h3><p>Python’s growth has resulted in numerous additional enhancements to the language. Python has incorporated important syntactical structures in recent versions (3.8 — 3.10), allowing for more powerful and efficient programming. The following are some of the most recent additions:</p><ul><li><a href="https://peps.python.org/pep-0572/"><strong>Assignment expressions</strong></a><strong>: </strong>In Python 3.8, a new <em>walrus operator</em> “:=” was added. The operator’s name is derived from the fact that it resembles the eyes and tusks of a walrus from the side.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BRHxRCF75o_D7I3R" /><figcaption>Photo by <a href="https://unsplash.com/es/@wolsenburg?utm_source=medium&amp;utm_medium=referral">Jay Ruzesky</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>An assignment expression is created by using the walrus operator. We can use the operator to assign a value to a variable within a Python expression. It’s a handy operator that helps us keep our code short.</p><pre>print(ready := True)</pre><p>In one step, we can assign and print a variable. Without the walrus operator we would write:</p><pre>ready = True<br>print(ready)</pre><p>You’d want to utilize it to avoid a variety of repetitions, such as <strong>repeated function calls</strong>, <strong>repeated statements</strong>, and <strong>repeated iterator calls</strong>.</p><ul><li><a href="https://docs.python.org/3/whatsnew/3.8.html#positional-only-parameters"><strong>Positional-only parameters</strong></a>: One of the many new features in the Python 3.8 version is the ability to specify positional-only arguments in function declarations by using the / marker. This change to the syntax improves efficiency and allows for better API design.</li><li><a href="https://peps.python.org/pep-0636/"><strong>Structural pattern matching</strong></a>: In Python 3.10, a new feature called ‘Structural Pattern Matching’ was included. In June 2020, PEP 622 proposed the syntax for this new functionality. Python’s pattern matching statement was inspired by Scala, Erlang, and other languages with comparable syntax. In its most basic form, it works similarly to the switch statement in C, C++, or Java.</li></ul><h3>Python testing</h3><p>We can all agree that no one, especially beginners, enjoys writing tests. Everyone agrees that this is a <em>good thing</em> to do, but only a few do it.</p><p>Testing in Python is a large topic with a lot of complexities, but it doesn’t have to be difficult. In a few simple steps, you can begin creating simple tests for your application and then expand from there.</p><p>While Python’s built-in testing framework, Unittest, isn’t bad by default, its design and behaviors are out of date. If you want to be more versatile and write less code, <a href="https://docs.pytest.org/en/7.1.x/"><strong>PyTest </strong></a>is the way to go.</p><h3>Conclusion</h3><p>If you want to be among the best, you should continually be on the lookout for new trends. There’s a reason maintainers release new versions; whether it’s to add new features that will make you a better developer or to patch bugs, you’ll only benefit from it.</p><p>Thank you for reading!</p><h3>References</h3><p><a href="https://docs.python.org/3/whatsnew/3.8.html">https://docs.python.org/3/whatsnew/3.8.html</a></p><p><a href="https://realpython.com/python-testing/">https://realpython.com/python-testing/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a5ccd4a4ee1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/3-things-to-make-you-a-superior-python-developer-in-2022-3a5ccd4a4ee1">3 things to make you a superior Python developer in 2023</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital signature in simple words]]></title>
            <link>https://medium.com/@georgievalexandro/digital-signature-in-simple-words-bcf1ae32db17?source=rss-f00d54402fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf1ae32db17</guid>
            <category><![CDATA[digital-signatures]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Alexandro Georgiev]]></dc:creator>
            <pubDate>Sat, 11 Jun 2022 08:22:43 GMT</pubDate>
            <atom:updated>2022-06-11T08:22:43.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TYzmnzDjOwNSwaoa" /><figcaption>Photo by <a href="https://unsplash.com/@signaturepro?utm_source=medium&amp;utm_medium=referral">Signature Pro</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, I’ll try to explain what a digital signature is in simple terms. <strong>A</strong><em> </em><strong>digital signature is an electronic version of a handwritten signature</strong>.<strong> </strong>They are commonly used for software distribution and financial transactions as well as other cases where it is important to detect fraudulent behavior.</p><h4>A digital signature serves three purposes</h4><ol><li><strong>Authentication</strong></li></ol><p>When you receive sensitive information, you want to be certain that it came from the person you believe sent it.</p><p>2. <strong>Non-repudiation</strong></p><p>With digital signature, the sender cannot deny the fact that he has sent the message.</p><p>3. <strong>Integrity</strong></p><p>Data integrity is particularly crucial during data transfers. A digital signature ensures that the message is not altered during transmission.</p><h4>How digital signatures work</h4><p>To demonstrate this, we will use two well-known characters in the IT world, Alice and Bob. In this scenario Bob will be the <em>sender </em>and Alice will be the <em>receiver</em>. Bob will send Alice a message signed with a <em>digital signature</em>.</p><ol><li>Bob begins by generating a key pair, one public and one private. He will keep the private key and send the public key to Alice.</li><li>After creating his message, Bob will use a <em>hash algorithm</em> to generate a unique digital fingerprint of data called <strong>digest</strong>.</li><li>Then he will encrypt the digest with his private key. This will create the <em>digital signature</em> for the message.</li><li>Bob then sends both the message and the signature to Alice.</li></ol><p>When Alice receives them, she will:</p><ol><li>Decrypt Bob’s signature with the public key he sent her earlier. This way she will generate a digest. If Alice cannot decrypt the digital signature then she knows it did not come from Bob since only his public key is able to decrypt the digest generated with his private key.</li><li>The second thing Alice will do is to check the integrity of the message she has received. She hashes the message with the same hash algorithm Bob used and compares the result with the digest she generated earlier from the signature. If they match, Alice will know for sure that the message has not been changed during transmission since Bob signed it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*x4bPJrkjpdAWmIUrOCOduA.png" /><figcaption>Key pair generation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*RXVo6rhRjH7n7gqHLVEpVw.png" /><figcaption>Digital signature in use illustration</figcaption></figure><p><em>Please note that this article focuses on </em><strong><em>how the digital signature works</em></strong><em> and does not address encrypting the message itself or what happens if an impostor obtains the public key.</em></p><p><strong>Thank you for reading 🙏.</strong></p><p><em>Credit to Sunny Sun whose videos inspired and helped me to write this article. His YouTube channel is Sunny Classroom —</em><a href="https://www.youtube.com/user/sunnylearning"><em>https://www.youtube.com/user/sunnylearning</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf1ae32db17" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>