<?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: crxs14</title>
    <description>The latest articles on DEV Community by crxs14 (@mahdizaabi).</description>
    <link>https://dev.to/mahdizaabi</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%2F557108%2Ff4845bce-fa88-4ecb-9f21-89edac4bbdaa.jpeg</url>
      <title>DEV Community: crxs14</title>
      <link>https://dev.to/mahdizaabi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mahdizaabi"/>
    <language>en</language>
    <item>
      <title>How Does the Shell Command ls -l work ?</title>
      <dc:creator>crxs14</dc:creator>
      <pubDate>Mon, 27 Sep 2021 21:30:51 +0000</pubDate>
      <link>https://dev.to/mahdizaabi/how-does-the-shell-command-ls-l-work-2p8o</link>
      <guid>https://dev.to/mahdizaabi/how-does-the-shell-command-ls-l-work-2p8o</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mm36pURJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sepayh9hzcmys1eyh2dr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mm36pURJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sepayh9hzcmys1eyh2dr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Linux ls command is used to list files and directories. By default, it will list the content of the current directory. In this article, I will show linux operate certain process and operations in order to execute this command .&lt;br&gt;
first thing first, before starting talking about the ls command, it’s important to understand how linux work …&lt;/p&gt;

&lt;p&gt;****Shell &amp;amp; command line :&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dMJLj0iO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53jginmeyg07nlpql7tr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dMJLj0iO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53jginmeyg07nlpql7tr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;****The system calls :&lt;br&gt;
To make this happens, Linux need to operate a succession of operations and tasks, to make the execution of a given command possible ..&lt;br&gt;
When a user type a command , the shell will first make a call to the kernel which is the heart of this operator system , asking him the permission to start executing a process…this fundamental step is called : a system call …&lt;br&gt;
Thanks to this function, the kernel will attribute a private identifier to this process (PID) , giving the birth to anew process that has the ability to exchange data with the kernel using the PID …&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;*Child process and PID :&lt;br&gt;
It’s important to mention that processes , like the human being , have a parental relation : a process when is born , called : a child Process , and the process that made the **fork()&lt;/strong&gt;system call , is the father …&lt;br&gt;
A child process inherits most of its attributes, such as file descriptors, from its parent. In Unix, a child process is typically created as a copy of the parent, using the fork system call. The child process can then overlay itself with a different program (using exec) as required. Each process may create many child processes but will have at most one parent process; if a process does not have a parent this usually indicates that it was created directly by the kernel. In some systems, including Linux-based systems, the very first process (called init) is started by the kernel at booting time and never terminates.&lt;br&gt;
After the &lt;strong&gt;fork()&lt;/strong&gt; system call , the operating system has now a free running child process available , so now we can make another function system call , called &lt;strong&gt;EXEC()&lt;/strong&gt; …. thanks to the exec function a new &lt;strong&gt;executable file&lt;/strong&gt; can run in the context of an already existing process (which is the child process) …&lt;/p&gt;

&lt;h4&gt;
  
  
  Command line interpretation :
&lt;/h4&gt;

&lt;p&gt;let’s go back now to our beloved command Ls , once the shell make the call for a new process , the shell tokenize first the input user(command), and fill it into a null terminated array .&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; In this array the executable file ls and argument -l are stored separately.
Once the command is stored , the program start searching for the full path of the executable file which is the ls in this case …&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2odGVXxw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwjg1ukjbybcn4vdpr95.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2odGVXxw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwjg1ukjbybcn4vdpr95.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The shell will look inside the PATH that contain all the environment variables , specifically in the /bin folder where most of the executable files are installed .&lt;br&gt;
If the corresponding path and executable file are found , the shell execute the command through the exec system call , otherwise an error message is printed the user interface .&lt;br&gt;
similarly , and after the executable file was found , the shell will attribute the given stored argument “-l” to the the exe file “Ls” …&lt;br&gt;
So no the full command ls -l is executed , and as a result , a full list of information about files and directories will be printed to the user interface :&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jIUw5d2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzrodhhs9gdxr5qfb9es.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jIUw5d2g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzrodhhs9gdxr5qfb9es.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Mutable and Immutable objects
</title>
      <dc:creator>crxs14</dc:creator>
      <pubDate>Mon, 27 Sep 2021 21:17:22 +0000</pubDate>
      <link>https://dev.to/mahdizaabi/mutable-and-immutable-objects-fim</link>
      <guid>https://dev.to/mahdizaabi/mutable-and-immutable-objects-fim</guid>
      <description>&lt;h4&gt;
  
  
  If you’ve just started using Python, so you probably heard the theories that everything in python is objects …
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Maybe it sounds weird at the beginning, but the further you dive deep on python, the more you start assimilating and understanding the concept of object thing .
&lt;/h4&gt;

&lt;p&gt;Nevertheless, let’s try today to explore together some basic notions and concepts related to our main topic, how objects are mutable and immutable in Python.&lt;/p&gt;

&lt;p&gt;Objects in Python could be either &lt;strong&gt;mutable&lt;/strong&gt; or &lt;strong&gt;immutable&lt;/strong&gt; …&lt;br&gt;
Like in science of genetics, the notion of mutation is basically how thing change with the time …Pythonic speaking,a single data object can represent something that evolves independently of the rest of the program. The behavior of a changing object may be influenced by its history, just like an entity in the world.&lt;br&gt;
The concept of mutation in Python could be identified and highlighted by two parameters: id and type …&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ID&lt;/strong&gt; :The built-in function id() returns the identity of an object as an integer. This integer usually corresponds to the object’s location in memory, although this is specific to the Python implementation and the platform being used. The is operator compares the identity of two objects.&lt;br&gt;
&lt;strong&gt;Type&lt;/strong&gt;:The built-in function type() and in association with the print function, print the type of an object. Lets look at a simple example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = "Holberton_Tunisia"
&amp;gt;&amp;gt;&amp;gt; id(a) = 1258755887 #this is the addressee memory where the              
                       #object is stored
type(a)
&amp;gt;&amp;gt;&amp;gt; &amp;lt;class: 'string'&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  why does it matter and how differently does Python treat mutable and immutable objects ?
&lt;/h4&gt;

&lt;p&gt;As we’ve said earlier, a mutation is the ability to change state through the time… So a mutable object can change its state or contents but there is also object that can not mutate … they are immutable .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 14 #a variable of type int
b = 14 #a variable of type int
#if we perform some logical operators:
a == b (TRUE)
a is b (TRUE)
#both of the two variables point to the same object
#simple operation:
a = a + 1
a == b (FALSE)
a is b (FALSE)
#modification of immutable objects is not possible
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s do the same but with mutable object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; Listx = list([1, 2, 3])
&amp;gt;&amp;gt;&amp;gt; listy = listx
&amp;gt;&amp;gt;&amp;gt; listx.append(2)
&amp;gt;&amp;gt;&amp;gt; print(listx)
&amp;gt;&amp;gt;&amp;gt; 1, 2, 3, 4
&amp;gt;&amp;gt;&amp;gt; print(listy)
&amp;gt;&amp;gt;&amp;gt; 1, 2, 3, 4
#the two objects hast been mutated 
listx == listy (TRUE)
listx is listy (TRUE)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, generally in &lt;strong&gt;Python&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mutable and immutable objects are handled differently . Immutable objects are quicker to access and not possible to change …
Whereas mutable objects are easy to change.
Use of mutable objects is recommended when there is a need to change the size or content of the object like Tuple .
But some exceptions are included here!!!
in fact we know that tuple in python is immutable. But the tuple consists of a sequence with unchangeable bindings to objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;tupl = (6, [3, 4, 5])&lt;/code&gt;    &lt;/p&gt;

&lt;p&gt;The tuple consists of an int and a list. int are immutable so we can’t change its value. But the contents of the list can change. &lt;strong&gt;The tuple itself isn’t mutable but contain items that are mutable.&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
