<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ℂ𝕠𝕠𝕕𝕚𝕟𝕘 𝔻𝕖𝕤𝕤𝕚𝕘𝕟</title>
    <description>The latest articles on DEV Community by ℂ𝕠𝕠𝕕𝕚𝕟𝕘 𝔻𝕖𝕤𝕤𝕚𝕘𝕟 (@coodignd).</description>
    <link>https://dev.to/coodignd</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F470550%2F0070bdae-2f09-45fb-b2f1-704440333ab7.jpg</url>
      <title>DEV Community: ℂ𝕠𝕠𝕕𝕚𝕟𝕘 𝔻𝕖𝕤𝕤𝕚𝕘𝕟</title>
      <link>https://dev.to/coodignd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coodignd"/>
    <language>en</language>
    <item>
      <title>What Are Javascript Method? A Guide to Javascript Methods</title>
      <dc:creator>ℂ𝕠𝕠𝕕𝕚𝕟𝕘 𝔻𝕖𝕤𝕤𝕚𝕘𝕟</dc:creator>
      <pubDate>Tue, 13 Apr 2021 09:16:44 +0000</pubDate>
      <link>https://dev.to/coodignd/what-are-javascript-method-a-guide-to-javascript-methods-2b7a</link>
      <guid>https://dev.to/coodignd/what-are-javascript-method-a-guide-to-javascript-methods-2b7a</guid>
      <description>&lt;h2&gt;
  
  
  1. What is a method
&lt;/h2&gt;

&lt;p&gt;Let’s define and call a regular function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet(who) {
  return `Hello, ${who}!`;
}

greet('World'); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function keyword followed by its name, params, and body: function greet(who) {...} makes a regular function definition.&lt;/p&gt;

&lt;p&gt;greet('World') is the regular function invocation. The function greet('World') accepts data from the argument.&lt;/p&gt;

&lt;p&gt;What if who is a property of an object? To easily access the properties of an object you can attach the function to that object, in other words, create a method.&lt;/p&gt;

&lt;p&gt;Let’s make greet() a method on the object world:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const world = {
  who: 'World',

  greet() {    return `Hello, ${this.who}!`;  }}

world.greet(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;greet() { ... }&lt;/code&gt; is now a method that belongs to the world object. world.greet() is a method invocation.&lt;/p&gt;

&lt;p&gt;Inside of the greet() method this points to the object the method belongs to — world. That’s why this.who expression accesses the property who.&lt;/p&gt;

&lt;p&gt;Note that this is also named context.&lt;/p&gt;

&lt;h2&gt;
  
  
  The context is optional
&lt;/h2&gt;

&lt;p&gt;While in the previous example I’ve used this to access the object the method belongs to — JavaScript, however, doesn’t impose a method to use this.&lt;/p&gt;

&lt;p&gt;For this reason you can use an object as a namespace of methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const namespace = {
  greet(who) {
    return `Hello, ${who}!`;
  },

  farewell(who) {
    return `Good bye, ${who}!`;
  }
}

namespace.greet('World');    
namespace.farewell('World'); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;namespace is an object that holds 2 methods: &lt;code&gt;namespace.greet()&lt;/code&gt; and &lt;code&gt;namespace.farewell()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The methods do not use this, and namespace serves as a holder of alike methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Object literal method
&lt;/h2&gt;

&lt;p&gt;As seen in the previous chapter, you can define a method directly in an object literal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const world = {
  who: 'World',

  greet() {    return `Hello, ${this.who}!`;  }};

world.greet(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;greet() { .... }&lt;/code&gt; is a method defined on an object literal. Such type of definition is named shorthand method definition (available starting ES2015).&lt;/p&gt;

&lt;p&gt;There’s also a longer syntax of methods definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const world = {
  who: 'World',

  greet: function() {    return `Hello, ${this.who}!`;  }}

world.greet(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;greet: function() { ... }&lt;/code&gt; is a method definition. Note the additional presence of a colon and &lt;code&gt;function&lt;/code&gt; keyword.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding methods dynamically
&lt;/h2&gt;

&lt;p&gt;The method is just a function that is stored as a property on the object. That’s why you can add methods dynamically to an object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const world = {
  who: 'World',

  greet() {
    return `Hello, ${this.who}!`;
  }
};


world.farewell = function () {
  return `Good bye, ${this.who}!`;
}

world.farewell(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;world&lt;/code&gt; object at first doesn’t have a method &lt;code&gt;farewell&lt;/code&gt;. It is added dynamically.&lt;/p&gt;

&lt;p&gt;The dynamically added method can be invoked as a method without problems: &lt;code&gt;world.farewell()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Class method
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the &lt;code&gt;class&lt;/code&gt; syntax defines a class that’s going to serve as a template for its instances.&lt;/p&gt;

&lt;p&gt;A class can also have methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Greeter {
  constructor(who) {
    this.who = who;
  }

  greet() {    console.log(this === myGreeter);     return `Hello, ${this.who}!`;  }}

const myGreeter = new Greeter('World');
myGreeter.greet(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;greet() { ... }&lt;/code&gt; is a method defined inside a class.&lt;/p&gt;

&lt;p&gt;Every time you create an instance of the class using new operator (e.g. &lt;code&gt;myGreeter = new Greeter('World')&lt;/code&gt;), methods are available for invocation on the created instance.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;myGreeter.greet()&lt;/code&gt; is how you invoke the method greet() on the instance. What’s important is that this inside of the method equals the instance itself: this equals &lt;code&gt;myGreeter&lt;/code&gt; inside &lt;code&gt;greet() { ... }&lt;/code&gt; method.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. How to invoke a method
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 Method invocation
&lt;/h3&gt;

&lt;p&gt;What’s particularly interesting about JavaScript is that defining a method on an object or class is half of the job. To maintain the method the context, you have to make sure to invoke the method as a… method.&lt;/p&gt;

&lt;p&gt;Let me show you why it’s important.&lt;/p&gt;

&lt;p&gt;Recall the world object having the method &lt;code&gt;greet()&lt;/code&gt; upon it. Let’s check what value has &lt;code&gt;this&lt;/code&gt; when &lt;code&gt;greet()&lt;/code&gt; is invoked as a method and as a regular function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const world = {
  who: 'World',

  greet() {
    console.log(this === world);    return `Hello, ${this.who}!`;
  }
};


world.greet(); 
const greetFunc = world.greet;

greetFunc(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;world.greet()&lt;/code&gt; is a method invocation. The object world, followed by a dot ., and finally the method itself — that’s what makes the method invocation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;greetFunc&lt;/code&gt; is the same function as world.greet. But when invoked as regular function &lt;code&gt;greetFunc()&lt;/code&gt;, this inside greet() isn’t equal to the world object, but rather to the global object (in a browser this is window).&lt;/p&gt;

&lt;p&gt;I name expressions like &lt;code&gt;greetFunc = world.greet&lt;/code&gt; separating a method from its object. When later invoking the separated method &lt;code&gt;greetFunc()&lt;/code&gt; would make this equal to the global object.&lt;/p&gt;

&lt;p&gt;Separating a method from its object can take different forms:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myMethodFunc = myObject.myMethod;


setTimeout(myObject.myMethod, 1000);


myButton.addEventListener('click', myObject.myMethod)


&amp;lt;button onClick={myObject.myMethod}&amp;gt;My React Button&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To avoid loosing the context of the method, make sure to use the method invocation world.greet() or bind the method manually to the object &lt;code&gt;greetFunc = world.greet.bind(this)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  4.2 Indirect function invocation
&lt;/h2&gt;

&lt;p&gt;As stated in the previous section, a regular function invocation has this resolved as the global object. Is there a way for a regular function to have a customizable value of this?&lt;/p&gt;

&lt;p&gt;Welcome the indirect function invocation, which can be performed using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myFunc.call(thisArg, arg1, arg2, ..., argN);
myFunc.apply(thisArg, [arg1, arg2, ..., argN]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;methods available on the function object.&lt;/p&gt;

&lt;p&gt;The first argument of &lt;code&gt;myFunc.call(thisArg)&lt;/code&gt; and &lt;code&gt;myFunc.apply(thisArg)&lt;/code&gt; is the context (the value of this) of the indirect invocation. In other words, you can manually indicate what value this is going to have inside the function.&lt;/p&gt;

&lt;p&gt;For example, let’s define &lt;code&gt;greet()&lt;/code&gt; as a regular function, and an object aliens having a who property:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet() {
  return `Hello, ${this.who}!`;
}

const aliens = {
  who: 'Aliens'
};

greet.call(aliens); 
greet.apply(aliens); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;greet.call(aliens)&lt;/code&gt; and &lt;code&gt;greet.apply(aliens)&lt;/code&gt; are both indirect method invocations. this value inside the &lt;code&gt;greet()&lt;/code&gt; function equals aliens object.&lt;/p&gt;

&lt;p&gt;The indirect invocation lets you emulate the method invocation on an object!&lt;/p&gt;

&lt;h2&gt;
  
  
  4.3 Bound function invocation
&lt;/h2&gt;

&lt;p&gt;Finally, here’s the third way how you can make a function be invoked as a method on an object. Specifically, you can bound a &lt;code&gt;function&lt;/code&gt; to have a specific context.&lt;/p&gt;

&lt;p&gt;You can create a bound function using a special method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const myBoundFunc = myFunc.bind(thisArg, arg1, arg2, ..., argN);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first argument of &lt;code&gt;myFunc.bind(thisArg)&lt;/code&gt; is the context to which the function is going to be bound to.&lt;/p&gt;

&lt;p&gt;For example, let’s reuse the &lt;code&gt;greet()&lt;/code&gt; and bind it to &lt;code&gt;aliens&lt;/code&gt; context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function greet() {
  return `Hello, ${this.who}!`;
}

const aliens = {
  who: 'Aliens'
};

const greetAliens = greet.bind(aliens);

greetAliens(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Calling greet.bind(aliens)&lt;/code&gt; creates a new function where this is bound to aliens object.&lt;/p&gt;

&lt;p&gt;Later, when invoking the bound function &lt;code&gt;greetAliens()&lt;/code&gt;, this equals aliens inside that function.&lt;/p&gt;

&lt;p&gt;Again, using a bound function you can emulate the method invocation.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Arrow functions as methods
&lt;/h2&gt;

&lt;p&gt;Using an arrow function as a method isn’t recommended, and here’s why.&lt;/p&gt;

&lt;p&gt;Let’s define the &lt;code&gt;greet()&lt;/code&gt; method as an arrow function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const world = {
  who: 'World',

  greet: () =&amp;gt; {
    return `Hello, ${this.who}!`;
  }
};

world.greet(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately, &lt;code&gt;world.greet()&lt;/code&gt; returns &lt;code&gt;'Hello, undefined!'&lt;/code&gt; instead of the expected &lt;code&gt;'Hello, World!'&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The problem is that the value this inside of the arrow function equals this of the outer scope. Always. But what you want is this to equal world object.&lt;/p&gt;

&lt;p&gt;That’s why this inside of the arrow function equals the global object: window in a browser. &lt;code&gt;'Hello, ${this.who}!'&lt;/code&gt; evaluates as Hello, &lt;code&gt;${windows.who}!&lt;/code&gt;, which in the end is &lt;code&gt;'Hello, undefined!'&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I like the arrow functions. But they don’t work as methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Summary
&lt;/h2&gt;

&lt;p&gt;The method is a function belonging to an object. The context of a method (&lt;code&gt;this&lt;/code&gt; value) equals the object the method belongs to.&lt;/p&gt;

&lt;p&gt;You can also define methods on classes. &lt;code&gt;this&lt;/code&gt; inside of a method of a class equals to the instance.&lt;/p&gt;

&lt;p&gt;What’s specific to JavaScript is that it is not enough to define a method. You also need to make sure to use a method invocation. Typically, the method invocation has the following syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myObject.myMethod('Arg 1', 'Arg 2');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Interestingly is that in JavaScript you can define a regular function, not belonging to an object, but then invoke that function as a method on an arbitrar object. You can do so using an indirect function invocation or bind a function to a particular context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;myRegularFunc.call(myObject, 'Arg 1', 'Arg 2');
myRegularFunc.apply(myObject, 'Arg 1', 'Arg 2');


const myBoundFunc = myRegularFunc.bind(myObject);
myBoundFunc('Arg 1', 'Arg 2');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Indirect invocation and bounding emulate the method invocation.&lt;/p&gt;

&lt;p&gt;Don't miss it:&lt;br&gt;
1.&lt;a href="https://www.coodingdessign.com/python/testdriven-io-django-and-pydantic/" rel="noopener noreferrer"&gt;TestDriven.io: Django and Pydantic&lt;/a&gt;&lt;br&gt;
2.&lt;a href="https://www.coodingdessign.com/python/python-pool-numpy-cross-product-in-python-with-examples/" rel="noopener noreferrer"&gt;Python Pool: NumPy Cross Product in Python with Examples&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbcsch3jafyv3zha10gp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbcsch3jafyv3zha10gp0.png" alt="Untitled"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>devops</category>
      <category>programming</category>
    </item>
    <item>
      <title>Methods in Python – A Key Concept of Object Oriented Programming</title>
      <dc:creator>ℂ𝕠𝕠𝕕𝕚𝕟𝕘 𝔻𝕖𝕤𝕤𝕚𝕘𝕟</dc:creator>
      <pubDate>Tue, 03 Nov 2020 12:28:01 +0000</pubDate>
      <link>https://dev.to/coodignd/methods-in-python-a-key-concept-of-object-oriented-programming-28ph</link>
      <guid>https://dev.to/coodignd/methods-in-python-a-key-concept-of-object-oriented-programming-28ph</guid>
      <description>&lt;p&gt;Overview&lt;br&gt;
Methods in Python are a crucial concept to understand as a programmer and a data science professional&lt;br&gt;
Here, we’ll talk about these different types of Methods in Python and how to implement the&lt;br&gt;
Introduction&lt;br&gt;
Python is a wonderful language but it can be daunting for a newcomer to master. Like any spoken language, Python requires us to first understand the basics before we can jump to building more diverse and broader applications in the data science field.&lt;/p&gt;

&lt;p&gt;Here’s the thing – if you cover your basics well, you’ll find Python to be a breeze. But it’s crucial to spend the initial learning time familiarizing yourself with the features Python offers. It’ll really pay off in the long run!&lt;/p&gt;

&lt;p&gt;Python is of course an Object-Oriented Programming (OOP) language. This is a wide concept and is not quite possible to grasp all at once. In fact, mastering OOP can take several months or even years. It totally depends upon your understanding capability. I highly recommend going through my previous article on the ‘Basic concepts of Object-Oriented Programming‘ first.&lt;/p&gt;

&lt;p&gt;So in this particular article, I’ll expand the concept of methods in Object-Oriented Programming further. We’ll talk about the different types of Methods in Python. Since python Methods can be confusing sometimes if you are new to OOP, I’ll cover methods in Python and their types in detail in this article. And then we’ll see the use cases of these methods.&lt;/p&gt;

&lt;p&gt;But wait – what are Python methods? Well, let’s begin and find out!&lt;/p&gt;

&lt;p&gt;If you’re completely new to Python, you should check out this free Python course that’ll teach you everything you need to get started in the data science world.&lt;/p&gt;

&lt;p&gt;Table of Contents&lt;br&gt;
What are Methods in Python?&lt;br&gt;
Types of Methods in Python&lt;br&gt;
Instance methods&lt;br&gt;
Class methods&lt;br&gt;
Static methods&lt;br&gt;
When to use Which type of Python Method?&lt;br&gt;
What are Methods in Python?&lt;br&gt;
The big question!&lt;/p&gt;

&lt;p&gt;In Object-Oriented Programming, we have (drum roll please) objects. These objects consist of properties and behavior. Furthermore, properties of the object are defined by the attributes and the behavior is defined using methods. These methods are defined inside a class. These methods are the reusable piece of code that can be invoked/called at any point in the program.&lt;/p&gt;

&lt;p&gt;Python offers various types of these methods. These are crucial to becoming an efficient programmer and consequently are useful for a data science professional.&lt;/p&gt;

&lt;p&gt;Types of Methods in Python&lt;br&gt;
There are basically three types of methods in Python:&lt;/p&gt;

&lt;p&gt;Instance Method&lt;br&gt;
Class Method&lt;br&gt;
Static Method&lt;br&gt;
Let’s talk about each method in detail.&lt;/p&gt;

&lt;p&gt;Instance Methods&lt;br&gt;
The purpose of instance methods is to set or get details about instances (objects), and that is why they’re known as instance methods. They are the most common type of methods used in a Python class.&lt;/p&gt;

&lt;p&gt;They have one default parameter- self, which points to an instance of the class. Although you don’t have to pass that every time. You can change the name of this parameter but it is better to stick to the convention i.e self.&lt;/p&gt;

&lt;p&gt;Any method you create inside a class is an instance method unless you specially specify Python otherwise. Let’s see how to create an instance method:&lt;/p&gt;

&lt;p&gt;class My_class:&lt;br&gt;
  def instance_method(self):&lt;br&gt;
    return "This is an instance method."&lt;br&gt;
It’s as simple as that!&lt;/p&gt;

&lt;p&gt;In order to call an instance method, you’ve to create an object/instance of the class. With the help of this object, you can access any method of the class.&lt;/p&gt;

&lt;p&gt;obj = My_class()&lt;br&gt;
obj.instance_method()&lt;br&gt;
Methods In Python - Instance Method&lt;/p&gt;

&lt;p&gt;When the instance method is called, Python replaces the self argument with the instance object, obj. That is why we should add one default parameter while defining the instance methods. Notice that when instance_method() is called, you don’t have to pass self.  Python does this for you.&lt;/p&gt;

&lt;p&gt;Along with the default parameter self, you can add other parameters of your choice as well:&lt;/p&gt;

&lt;p&gt;class My_class:&lt;/p&gt;

&lt;p&gt;def instance_method(self, a):&lt;br&gt;
    return f"This is an instance method with a parameter a = {a}."&lt;br&gt;
We have an additional parameter “a” here. Now let’s create the object of the class and call this instance method:&lt;/p&gt;

&lt;p&gt;obj = My_class()&lt;br&gt;
obj.instance_method(10)&lt;br&gt;
Methods In Python&lt;/p&gt;

&lt;p&gt;Again you can see we have not passed ‘self’ as an argument, Python does that for us. But have to mention other arguments, in this case, it is just one. So we have passed 10 as the value of “a”.&lt;/p&gt;

&lt;p&gt;You can use “self” inside an instance method for accessing the other attributes and methods of the same class:&lt;/p&gt;

&lt;p&gt;class My_class:&lt;/p&gt;

&lt;p&gt;def &lt;strong&gt;init&lt;/strong&gt;(self, a, b):&lt;br&gt;
    self.a = a&lt;br&gt;
    self.b = b&lt;/p&gt;

&lt;p&gt;def instance_method(self):&lt;br&gt;
    return f"This is the instance method and it can access the variables a = {self.a} and&lt;br&gt;
 b = {self.b} with the help of self."&lt;br&gt;
Note that the &lt;strong&gt;init&lt;/strong&gt;() method is a special type of method known as a constructor. This method is called when an object is created from the class and it allows the class to initialize the attributes of a class.&lt;/p&gt;

&lt;p&gt;obj = My_class(2,4)&lt;br&gt;
obj.instance_method()&lt;br&gt;
Methods In Python&lt;/p&gt;

&lt;p&gt;With the help of the “self” keyword- self.a and self.b, we have accessed the variables present in the &lt;strong&gt;init&lt;/strong&gt;() method of the same class.&lt;/p&gt;

&lt;p&gt;Along with the objects of a class, an instance method can access the class itself with the help of self.&lt;strong&gt;class&lt;/strong&gt; attribute. Let’s see how:&lt;/p&gt;

&lt;p&gt;class My_class():&lt;/p&gt;

&lt;p&gt;def instance_method(self):&lt;br&gt;
    print("Hello! from %s" % self.&lt;strong&gt;class&lt;/strong&gt;.&lt;strong&gt;name&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;obj = My_class()&lt;br&gt;
obj.instance_method()&lt;br&gt;
Methods In Python&lt;br&gt;
The self.&lt;strong&gt;class&lt;/strong&gt;.&lt;strong&gt;name&lt;/strong&gt; attribute returns the name of the class to which class instance(self) is related.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Class Methods
The purpose of the class methods is to set or get the details (status) of the class. That is why they are known as class methods. They can’t access or modify specific instance data. They are bound to the class instead of their objects. Two important things about class methods:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In order to define a class method, you have to specify that it is a class method with the help of the @classmethod decorator&lt;br&gt;
Class methods also take one default parameter- cls, which points to the class. Again, this not mandatory to name the default parameter “cls”. But it is always better to go with the conventions&lt;br&gt;
Now let’s look at how to create class methods:&lt;/p&gt;

&lt;p&gt;class My_class:&lt;/p&gt;

&lt;p&gt;@classmethod&lt;br&gt;
  def class_method(cls):&lt;br&gt;
    return "This is a class method."&lt;br&gt;
As simple as that!&lt;/p&gt;

&lt;p&gt;As I said earlier, with the help of the instance of the class, you can access any method. So we’ll create the instance of this My_class as well and try calling this class_method():&lt;/p&gt;

&lt;p&gt;obj = My_class()&lt;br&gt;
obj.class_method()&lt;br&gt;
Methods In Python&lt;/p&gt;

&lt;p&gt;This works too! We can access the class methods with the help of a class instance/object. But we can access the class methods directly without creating an instance or object of the class. Let’s see how:&lt;/p&gt;

&lt;p&gt;My_class.class_method()&lt;br&gt;
Methods In Python&lt;/p&gt;

&lt;p&gt;Without creating an instance of the class, you can call the class method with – Class_name.Method_name().&lt;/p&gt;

&lt;p&gt;But this is not possible with instance methods where we have to create an instance of the class in order to call instance methods. Let’s see what happens when we try to call the instance method directly:&lt;/p&gt;

&lt;p&gt;My_class.instance_method()&lt;br&gt;
Methods In Python - Error&lt;/p&gt;

&lt;p&gt;We got an error stating missing one positional argument – “self”.  And it is obvious because instance methods accept an instance of the class as the default parameter. And you are not providing any instance as an argument. Though this can be bypassing the object name as the argument:&lt;/p&gt;

&lt;p&gt;My_class.instance_method(obj)&lt;/p&gt;

&lt;p&gt;Awesome!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Static Methods
Static methods cannot access the class data. In other words, they do not need to access the class data. They are self-sufficient and can work on their own.  Since they are not attached to any class attribute, they cannot get or set the instance state or class state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In order to define a static method, we can use the @staticmethod decorator (in a similar way we used @classmethod decorator). Unlike instance methods and class methods, we do not need to pass any special or default parameters. Let’s look at the implementation:&lt;/p&gt;

&lt;p&gt;class My_class:&lt;/p&gt;

&lt;p&gt;@staticmethod&lt;br&gt;
  def static_method():&lt;br&gt;
    return "This is a static method."&lt;br&gt;
And done!&lt;/p&gt;

&lt;p&gt;Notice that we do not have any default parameter in this case. Now how do we call static methods? Again, we can call them using object/instance of the class as:&lt;/p&gt;

&lt;p&gt;obj = My_class()&lt;br&gt;
obj.static_method()&lt;/p&gt;

&lt;p&gt;And we can call static methods directly, without creating an object/instance of the class:&lt;/p&gt;

&lt;p&gt;My_class.static_method()&lt;/p&gt;

&lt;p&gt;You can notice the output is the same using both ways of calling static methods.&lt;/p&gt;

&lt;p&gt;Here’s a summary of the explanation we’ve seen:&lt;/p&gt;

&lt;p&gt;An instance method knows its instance (and from that, it’s class)&lt;br&gt;
A class method knows its class&lt;br&gt;
A static method doesn’t know its class or instance&lt;br&gt;
When to Use Which Python Method?&lt;br&gt;
The instance methods are the most commonly used methods. Even then there is difficulty in knowing when you can use class methods or static methods. The following explanation will satiate your curiosity:&lt;/p&gt;

&lt;p&gt;Class Method – The most common use of the class methods is for creating factory methods. Factory methods are those methods that return a class object (like a constructor) for different use cases. Let’s understand this using the given example:&lt;/p&gt;

&lt;p&gt;from datetime import date&lt;/p&gt;

&lt;p&gt;class Dog:&lt;br&gt;
  def &lt;strong&gt;init&lt;/strong&gt;(self, name, age):&lt;br&gt;
    self.name = name&lt;br&gt;
    self.age = age&lt;/p&gt;

&lt;h1&gt;
  
  
  a class method to create a Dog object with birth year.
&lt;/h1&gt;

&lt;p&gt;@classmethod&lt;br&gt;
  def Year(cls, name, year):&lt;br&gt;
    return cls(name, date.today().year - year)&lt;br&gt;
Here as you can see, the class method is modifying the status of the class. If we have the year of birth of any dog instead of the age, then with the help of this method we can modify the attributes of the class.&lt;/p&gt;

&lt;p&gt;Let’s check this:&lt;/p&gt;

&lt;p&gt;Dog1 = Dog('Bruno', 1)&lt;br&gt;
Dog1.name , Dog1.age&lt;/p&gt;

&lt;p&gt;Here we have constructed an object of the class. This takes two parameters name and age. On printing the attributes of the class we get Bruno and 1 as output, which was the values we provided.&lt;/p&gt;

&lt;p&gt;Dog2 = Dog.Year('Dobby', 2017)&lt;br&gt;
Dog2.name , Dog2.age&lt;/p&gt;

&lt;p&gt;Here, we have constructed another object of the class Dog using the class method Year(). The Year() method takes Person class as the first parameter cls and returns the constructor by calling cls(name, date.today().year – year), which is equivalent to Dog(name, date.today().year – year).&lt;/p&gt;

&lt;p&gt;As you can see in printing the attributes name and age we got the name that we provided and the age converted from the year of birth using the class method.&lt;/p&gt;

&lt;p&gt;Static Method – They are used for creating utility functions. For accomplishing routine programming tasks we use utility functions. A simple example could be:&lt;/p&gt;

&lt;p&gt;class Calculator:&lt;/p&gt;

&lt;p&gt;@staticmethod&lt;br&gt;
  def add(x, y):&lt;br&gt;
    return x + y&lt;/p&gt;

&lt;p&gt;print('The sum is:', Calculator.add(15, 10))&lt;/p&gt;

&lt;p&gt;You can see that the use-case of this static method is very clear, adding the two numbers given as parameters. Whenever you have to add two numbers, you can call this method directly without worrying about object construction.&lt;/p&gt;

&lt;p&gt;End Notes&lt;br&gt;
In this article, we learned about Python methods, types of methods and saw how to implement each method.&lt;/p&gt;

&lt;p&gt;I recommend you go through these resources on Object-Oriented Programming-&lt;/p&gt;

&lt;p&gt;Let me know in the comments section below if you have any queries or feedback. Happy learning!&lt;/p&gt;

&lt;p&gt;Orginally published from &lt;a href="https://bit.ly/3jNpvl2"&gt;https://bit.ly/3jNpvl2&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deep Learning for Signal Processing: What You Need to Know</title>
      <dc:creator>ℂ𝕠𝕠𝕕𝕚𝕟𝕘 𝔻𝕖𝕤𝕤𝕚𝕘𝕟</dc:creator>
      <pubDate>Thu, 17 Sep 2020 06:57:45 +0000</pubDate>
      <link>https://dev.to/coodignd/deep-learning-for-signal-processing-what-you-need-to-know-1m7m</link>
      <guid>https://dev.to/coodignd/deep-learning-for-signal-processing-what-you-need-to-know-1m7m</guid>
      <description>&lt;p&gt;Signal Processing is a part of electrical designing that models and examines information portrayals of physical occasions. It is at the center of the computerized world. What's more, presently, signal handling is beginning to make a few waves in deep learning.&lt;/p&gt;

&lt;p&gt;Using Deep Learning for Signal Processing&lt;/p&gt;

&lt;p&gt;As per the Institute of Electrical and Electronic Engineers (IEEE), Signal Processing typifies our every day lives with no of us in any event, knowing. PCs, radios, recordings, cell phones are completely empowered by signal preparing. Signal Processing is a part of electrical building that models and examines information portrayals of physical occasions. It is at the center of the computerized world. Discourse and sound, independent driving, picture handling, wearable innovation, and correspondence frameworks all work because of sign preparing. Also, presently, signal preparing is beginning to make a few waves in deep learning.&lt;/p&gt;

&lt;p&gt;What is a Signal?&lt;/p&gt;

&lt;p&gt;A signal is a physical help of data. As indicated by the above chart, signal preparing is the convergence of Mathematics, Informatics and Physical upgrades. Signs incorporate practically all types of information that can be digitized, for example, pictures, recordings, sound and sensor information. Science is important to assess it, Informatics empowers the usage and the physical world will create the signals.&lt;/p&gt;

&lt;p&gt;Deep Learning for Signal Data&lt;/p&gt;

&lt;p&gt;Deep learning for signal data requires extra steps when compared to applying deep learning or machine learning to other data sets. Good quality signal data is hard to obtain and has so much noise and variability. Wideband noise, jitters, and distortions are just a few of the unwanted characteristics found in most signal data.&lt;/p&gt;

&lt;p&gt;As with all deep learning projects, and especially for signal data, your success will almost always depend on how much data you have and the computational power of your machine, so a good deep learning workstation is highly recommended.&lt;/p&gt;

&lt;p&gt;To sidestep utilizing deep learning, a careful comprehension of sign information and sign preparing will be required so as to utilize AI strategies which depends on less information than deep learning.&lt;/p&gt;

&lt;h1&gt;
  
  
  1: Firstly, the cycle would include putting away, perusing and pre-handling the information. This will likewise include separating and changing highlights and parting into preparing and test sets. In the event that you are intending to utilize a directed learning calculation, the information will require naming.
&lt;/h1&gt;

&lt;h1&gt;
  
  
  2: Visualizing the information will be critical to distinguishing the kind of pre-handling and highlight extraction procedures that will be required. For signal handling, imagining is required in the time, recurrence and time-recurrence spaces for legitimate investigation.
&lt;/h1&gt;

&lt;h1&gt;
  
  
  3: Once the information has been imagined, it will be important to change and concentrate highlights from the information, for example, tops, change focuses and signal examples.
&lt;/h1&gt;

&lt;p&gt;Prior to the coming of AI or profound learning, old style models for time arrangement investigation were utilized since signals have a period explicit area. &lt;/p&gt;

&lt;p&gt;Old style Time Series Analysis &lt;/p&gt;

&lt;p&gt;Visual review of time arrangement, taking a gander at change after some time, investigating pinnacles and troughs. &lt;/p&gt;

&lt;p&gt;Recurrence Domain Analysis &lt;/p&gt;

&lt;p&gt;As indicated by MathWorks, Frequency Domain Analysis is one of the key parts of Signal Processing. It is utilized in regions, for example, Communications, Geology, Remote Sensing, and Image Processing. Time Domain Analysis shows a sign's vitality appropriated after some time while a recurrence space portrayal remembers data for the stage move that must be applied to every recurrence segment so as to recuperate the first run through sign with a blend of all the individual recurrence segments. A sign is changed among time and recurrence areas utilizing numerical administrators called a "Change". Two celebrated instances of this are Fast Fourier Transform (FFT) and the Discrete Fourier Transform (DFT).&lt;/p&gt;

&lt;p&gt;Long Short-Term Memory Models (LSTM’s) for Human Activity Recognition (HAR)&lt;/p&gt;

&lt;p&gt;Human Activity Recognition (HAR) has been picking up footing lately with the appearance of propelling human PC cooperations. It has true applications in enterprises extending from medical services, wellness, gaming, military and route. There are 2 kinds of HAR: &lt;/p&gt;

&lt;p&gt;Sensor based HAR (wearables that are appended to a human body and human action is converted into explicit sensor signal examples that can be fragmented and recognized). Most examination has moved to a sensor based methodology because of headway in sensor innovation and its ease. &lt;/p&gt;

&lt;p&gt;Outside Device HAR &lt;/p&gt;

&lt;p&gt;Profound Learning methods have been utilized to beat the weaknesses of AI strategies that follow heuristics framed by the client. Profound Learning techniques that can consequently separate highlights, scale better for more mind boggling undertakings. Sensor information is developing at a quick pace (eg: Apple Watch, Fitbit, passerby following and so on) and the measure of information created is adequate for profound learning strategies to learn and produce more exact outcomes. &lt;/p&gt;

&lt;p&gt;Intermittent Neural Networks are a reasonable decision for signal information as it intrinsically has a period part, consequently a consecutive segment. This Paper: Deep Recurrent Neural Networks for Human Activity Recognition traces some LSTM based Deep RNN's to assemble HAR models for ordering exercises planned from variable length input arrangements.&lt;/p&gt;

&lt;p&gt;for more updates over deep learning and datascience please reach at &lt;a href="https://coodingdessign.com"&gt;https://coodingdessign.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Backup SQL databases on the AWS S3 bucket using Windows PowerShell  
</title>
      <dc:creator>ℂ𝕠𝕠𝕕𝕚𝕟𝕘 𝔻𝕖𝕤𝕤𝕚𝕘𝕟</dc:creator>
      <pubDate>Thu, 17 Sep 2020 06:43:38 +0000</pubDate>
      <link>https://dev.to/coodignd/backup-sql-databases-on-the-aws-s3-bucket-using-windows-powershell-if8</link>
      <guid>https://dev.to/coodignd/backup-sql-databases-on-the-aws-s3-bucket-using-windows-powershell-if8</guid>
      <description>&lt;p&gt;In this article, we will explore taking backups of native SQL databases into the AWS S3 bucket.&lt;/p&gt;

&lt;p&gt;Please click on the link below to read the complete article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bit.ly/2RBzuym"&gt;https://bit.ly/2RBzuym&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
    </item>
  </channel>
</rss>
