As some of you know that I used to do the mentoring of students to improve their employability at a personal capacity. I thought I should give a formal structure to it as I continue to create impact. We are seeing career transformation and the time is just right.
I am merging my contributions in mentoring through GeeksHub, where I will be serving as an advisor. GeeksHub is an upskilling company primarily targeting entry and mid-level software engineer to improve their hard skills (coding, technology and related). You can find more about them here
I will continue to use this blog for technical/technology discussions and others related to technology. I will refrain posting general stuff related to life (but you never know)
More on GeeksHub in next post :-)
Showing posts with label Technology. Show all posts
Showing posts with label Technology. Show all posts
15 April 2019
10 January 2018
Get, Set, GOLANG
[Reading Time: 3 to 5 minutes]
[Edited] Reposting this as i have decided to change the book.
[Edited] Reposting this as i have decided to change the book.
Looks like programming languages are sweeping the internet today. Ever since the programming languages were introduced, the pace of new languages was rising gradually. Today, we are seeing a higher pace of several new and promising languages. Python and Go seem to take up cloud software development quite strongly. Python has been around for a lot of time. Go seems to pick up - offering ease of development comparable to languages like Python and giving a speed of execution of that of C/C++. From now and for next few months, I have to ride two horses - learning both Python and Go. I have to admit that I cannot put off my temptation (which I kept off for last three months).
![]() |
| Go in Action by William Kennedy and Others |
It consists of 9 chapters (270 pages). The chapters are said to be designed in such a way that an intermediate programmer can get best out of it (the audience the folks with some programming experience but new to Go, so no boring stuff). This is a quite a promise to keep up. I am excited to ride two horses.
Let us see how it goes. I am excited to learn Go and share my reading journal with you on Go :-)
There is another language that is creating so much noise - Rust. Check it out. If you are a C guy, you have to watch out Rust (hoping that I will not jump the gun in learning Rust)
Note 1: You will see "Reading Time" in all my posts. I want to alert you how much time you are likely to invest reading my posts so that you can decide when and whether to read the post.
Note 2: My goal is to keep it short and give you links in every page to read posts relevant each post
[Update after reading first chapter and reading the second chapter after half way through]
Looks to me that Go In Action has taken the learning in a different perspective and I am certainly feeling little tired to get past each sections. Somehow, I feel this should not be my first book on Go and I am going to switch to another book - which probably offers step by step in small increments.
Note 1: You will see "Reading Time" in all my posts. I want to alert you how much time you are likely to invest reading my posts so that you can decide when and whether to read the post.
Note 2: My goal is to keep it short and give you links in every page to read posts relevant each post
[Update after reading first chapter and reading the second chapter after half way through]
Looks to me that Go In Action has taken the learning in a different perspective and I am certainly feeling little tired to get past each sections. Somehow, I feel this should not be my first book on Go and I am going to switch to another book - which probably offers step by step in small increments.
07 January 2018
"Learning Python by Mark Lutz" - Reading Journal 6 [Chapter 10, Chapter 11 and Chapter 12]
![]() |
| Learning Python by Mark Lutz |
For next few months, I would be posting my experiences with Python more specifically the learning I am going through from the book - "Learning Python by Mark Lutz". You can find all of my reading journal of this book.
The rest of this post covers what I learned in Chapter 10, Chapter 11 and Chapter 12.
Chapter 10: Introducing Python Statements
This chapter is fairly easy to read. By now you should have written some code with statements which should make this chapter even more easier. But an important take away is "why Python is Pythonic" with to respect statements, code blocks, and indentation. Towards the end, we also see few nice and quick examples.
Chapter 11: Assignments, Expressions, and Prints
This is another great chapter that covers assignments, expressions, and prints in great detail. It details various ways of assignments, sequence unpacking, sequence assignments and augmented assignments. Variable naming rules, conventions, and expression statements are discussed too. Towards the end, there is a good section on prints and various ways of printing covering both 2.x, 3.x, and printing in version neutral way. Another great chapter.
Chapter 12: if Tests and Syntax Rules
This chapter gives an in-depth treatment of if constructs & its optional extension (elif, else) giving examples of nested and deeply nested if constructs, multiway branching. The most valuable content is the discussion on indentation and philosophy of Python with respect to code readability in the light of software maintenance. Truth values, boolean tests and if/else ternary operations are discussed. I suggest to stop here for a while and then try out examples so that the concepts are understood well.
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
Chapter 10: Introducing Python Statements
This chapter is fairly easy to read. By now you should have written some code with statements which should make this chapter even more easier. But an important take away is "why Python is Pythonic" with to respect statements, code blocks, and indentation. Towards the end, we also see few nice and quick examples.
Chapter 11: Assignments, Expressions, and Prints
This is another great chapter that covers assignments, expressions, and prints in great detail. It details various ways of assignments, sequence unpacking, sequence assignments and augmented assignments. Variable naming rules, conventions, and expression statements are discussed too. Towards the end, there is a good section on prints and various ways of printing covering both 2.x, 3.x, and printing in version neutral way. Another great chapter.
Chapter 12: if Tests and Syntax Rules
This chapter gives an in-depth treatment of if constructs & its optional extension (elif, else) giving examples of nested and deeply nested if constructs, multiway branching. The most valuable content is the discussion on indentation and philosophy of Python with respect to code readability in the light of software maintenance. Truth values, boolean tests and if/else ternary operations are discussed. I suggest to stop here for a while and then try out examples so that the concepts are understood well.
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
05 January 2018
"Learning Python by Mark Lutz" - Reading Journal 5 [Chapter 8 and Chapter 9]
![]() |
| Learning Python by Mark Lutz |
For next few months, I would be posting my experiences with Python more specifically the learning I am going through from the book - "Learning Python by Mark Lutz". You can find all of my reading journal of this book.
The rest of this post covers what I learned in Chapter 8 and Chapter 9.
Chapter 8: List and Dictionaries
This chapter has given a lot of information in lists and directories. The key thing is that each operation is shown with examples. If you have gone through the chapter on "string", the list should be similar and you can just zip it through. The operations such as create, modify, slice, sequencing, iteration, comprehension and in place modification with loads of examples. Once you are through this chapter, you will understand (and relate to) if someone says you need not memorize things in Python. It was a very good read.
Chapter 9: Tuples, Files, and Everything Else
This chapter gives a nice exposition on tuples, named tuples, files and overview/summary of types that are discussed so far. At this point in time, I have to admit that Python is becoming easier to comprehend. Since we have seen lists/dictionary already, tuples and named tuples are similar except that they are immutable. With respect to files, I learned how to read, write, seek and flush the buffers, iterate over lines, opening them in the binary mode which turns off encoding/decoding Unicode, introduction to pickle, JSON & struct and file context manager. The chapter closes with a lengthy overview of types giving us a treat.
With this, I have completed Part 2 of the book roughly 20% of the book. Still, I have 80% to cover but it is exciting :-). Overall, my impression is - part 2 is deeper and insightful than part1 (with no offense meant to part1)
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
Chapter 8: List and Dictionaries
This chapter has given a lot of information in lists and directories. The key thing is that each operation is shown with examples. If you have gone through the chapter on "string", the list should be similar and you can just zip it through. The operations such as create, modify, slice, sequencing, iteration, comprehension and in place modification with loads of examples. Once you are through this chapter, you will understand (and relate to) if someone says you need not memorize things in Python. It was a very good read.
Chapter 9: Tuples, Files, and Everything Else
This chapter gives a nice exposition on tuples, named tuples, files and overview/summary of types that are discussed so far. At this point in time, I have to admit that Python is becoming easier to comprehend. Since we have seen lists/dictionary already, tuples and named tuples are similar except that they are immutable. With respect to files, I learned how to read, write, seek and flush the buffers, iterate over lines, opening them in the binary mode which turns off encoding/decoding Unicode, introduction to pickle, JSON & struct and file context manager. The chapter closes with a lengthy overview of types giving us a treat.
With this, I have completed Part 2 of the book roughly 20% of the book. Still, I have 80% to cover but it is exciting :-). Overall, my impression is - part 2 is deeper and insightful than part1 (with no offense meant to part1)
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
04 January 2018
"Learning Python by Mark Lutz" - Reading Journal 4 [Chapter 6 and Chapter 7]
![]() |
| Learning Python by Mark Lutz |
For next few months, I would be posting my experiences with Python more specifically the learning I am going through from the book - "Learning Python by Mark Lutz". You can find all of my reading journal of this book.
The rest of this post covers what I learned in Chapter 6 and Chapter 7.
Chapter 6: The Dynamic Typing Interlude
This chapter provides an excellent coverage of dynamic types, objects, variables and a picture on how the objects are created in memory. Dynamic typing - how Python detects the type (or rather where it stores the type of the object), the significance of variable names, object reference counts and where the variable names are stored are discussed. A brief walkthrough on automatic reclaim of memory (aka Garbage Collection) and GC in the context of shared references, shared references and In-place changes and shared references and equality are discussed. If you are from the language like Java, you should be knowing most of the concepts already. Overall a nice theoretical view of PVM memory and object space. Nice and neat chapter
Chapter 7: String Fundamentals
If you like strings and string manipulation - I bet you will like this chapter. What appears as simple (when we do no know) becomes quite overwhleming when we go deeper. This chapter is written in such a way that it never overwhelms with a lot of friendly advices. Do not miss this chapter if you are a fan of strings. Let us come what I learned. String, why string is a sequence, string liternals, escape sequences, raw strings, unicode representation, how to express strings (three different ways), indexing, slicing, extended slicing, conversion, changing strings, immutablity, string methods, string module (which you should be using), formatting expressions. After reading the chapter, I feel that this is one of the chapters that I should read few times. I am sure that strings will take some time to master. Overall, the chapter is nice, informative. Kudos to the author again.
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
Chapter 6: The Dynamic Typing Interlude
This chapter provides an excellent coverage of dynamic types, objects, variables and a picture on how the objects are created in memory. Dynamic typing - how Python detects the type (or rather where it stores the type of the object), the significance of variable names, object reference counts and where the variable names are stored are discussed. A brief walkthrough on automatic reclaim of memory (aka Garbage Collection) and GC in the context of shared references, shared references and In-place changes and shared references and equality are discussed. If you are from the language like Java, you should be knowing most of the concepts already. Overall a nice theoretical view of PVM memory and object space. Nice and neat chapter
Chapter 7: String Fundamentals
If you like strings and string manipulation - I bet you will like this chapter. What appears as simple (when we do no know) becomes quite overwhleming when we go deeper. This chapter is written in such a way that it never overwhelms with a lot of friendly advices. Do not miss this chapter if you are a fan of strings. Let us come what I learned. String, why string is a sequence, string liternals, escape sequences, raw strings, unicode representation, how to express strings (three different ways), indexing, slicing, extended slicing, conversion, changing strings, immutablity, string methods, string module (which you should be using), formatting expressions. After reading the chapter, I feel that this is one of the chapters that I should read few times. I am sure that strings will take some time to master. Overall, the chapter is nice, informative. Kudos to the author again.
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
01 January 2018
"Learning Python by Mark Lutz" - Reading Journal 3 [Chapter 4 and Chapter 5]
![]() |
| Learning Python by Mark Lutz |
For next few months, I would be posting my experiences with Python more specifically the learning I am going through from the book - "Learning Python by Mark Lutz". You can find all of my reading journal of this book
The rest of this post covers what I learned in Chapter 4 and Chapter 5.
Chapter 4: Introducing Python Object Types
As the chapter title says, this chapter introduces core data types that are built-in to Python - Numeric, String, Lists, Dictionaries. It also gives an overview of Files, Set, and user-defined classes. It talks about sequences, mappings, and sets. How to iterate over collections and access mappings/dictionaries. What are type-specific functions available. On files, a simple read/write with encoding/decoding is discussed at a higher level. At the end of this chapter, you will realize that everything is object in Python (and dynamic/strick typing system). It was very interesting to read. On the downside, I am still curious as to when I will write some code. I do not see coding exercises/puzzles at the end of the chapter yet.
Chapter 5: Numeric Types
What we think as just integers and floats are mind-boggling when we try to go little deeper. This chapter is no exception especially when you have two versions of Python (2.x and 3.x) behave little differently. I am pretty sure that numeric types and differences in two major versions of Python are going to be little tough to remember and one has to keep referring the material until it becomes second nature. Let us come to the learning.
This chapter covers numeric types - integers, floats, decimal, fraction, complex numbers, operators, building expressions, precedence, bitwise operators, comprehension, sets, booleans, evaluation of tests, chained tests, representing numbers in other bases (hex, octal and binary) and finally some introduction on number crunching with popular modules. I strongly suggest practicing while you read to get the feel of what the author says. The chapter was longer with so many details but never boring though. Truly great stuff.
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
Chapter 4: Introducing Python Object Types
As the chapter title says, this chapter introduces core data types that are built-in to Python - Numeric, String, Lists, Dictionaries. It also gives an overview of Files, Set, and user-defined classes. It talks about sequences, mappings, and sets. How to iterate over collections and access mappings/dictionaries. What are type-specific functions available. On files, a simple read/write with encoding/decoding is discussed at a higher level. At the end of this chapter, you will realize that everything is object in Python (and dynamic/strick typing system). It was very interesting to read. On the downside, I am still curious as to when I will write some code. I do not see coding exercises/puzzles at the end of the chapter yet.
Chapter 5: Numeric Types
What we think as just integers and floats are mind-boggling when we try to go little deeper. This chapter is no exception especially when you have two versions of Python (2.x and 3.x) behave little differently. I am pretty sure that numeric types and differences in two major versions of Python are going to be little tough to remember and one has to keep referring the material until it becomes second nature. Let us come to the learning.
This chapter covers numeric types - integers, floats, decimal, fraction, complex numbers, operators, building expressions, precedence, bitwise operators, comprehension, sets, booleans, evaluation of tests, chained tests, representing numbers in other bases (hex, octal and binary) and finally some introduction on number crunching with popular modules. I strongly suggest practicing while you read to get the feel of what the author says. The chapter was longer with so many details but never boring though. Truly great stuff.
All posts related to "Learning Python by Mark Lutz"
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
31 December 2017
"Learning Python by Mark Lutz" - Reading Journal 2 [Chapter 2 and Chapter 3]
![]() |
| Learning Python by Mark Lutz |
For next few months, I would be posting my experiences with Python more specifically the learning I am going through from the book - "Learning Python by Mark Lutz". You can find all of my reading journal of this book and accompanying code in GitHub
The rest of this post covers what I learned in Chapter 2 and Chapter 3.
Chapter 2: How Python Runs Programs
This chapter introduces you a needed theoretical overview of Python runtime (interpreter) and Python bytecode. The execution of the program is explained in two viewpoints - programmer's view and Python's view. The programmers' view is what code to be written following the language constructs generating source code and Python's view is how to execute the program converting source code to actual functionality (the output of programmer view is input to Python's view). The chapter offers execution model variations (different runtime models - CPython, Jython, Stackless, PyPy) and optimization tools (Psyco JIT, Shed Skin, Cthyon). This chapter is wonderfully written and there will be some learning to everyone. I thoroughly enjoyed the content :-). Kudos to the author for covering a variety of insights.
Chapter 3: How You Run Programs
I need to start with a warning. This chapter has so much information and ways to run your code like "from the command line", "interactive", "IDLE" and "IDE". I personally suggest that we should try all the methods at least once and choose one of the methods. I find IDE convenient. Yes, I do use PyCharm community edition. On the good side, the chapter introduces modules, importing, namespaces, module reloads which is quite interesting. Good round up of exercises at the end. I do not want to bog you down with a lot of details. One little advice I have for you is to take breaks while reading this chapter and be prepared for a long haul. Without the break, I feel this chapter is little tough to complete and might appear daunting (and might be demotivating to complete). The good thing about such details are completeness
BTW, with this, we complete the first part of the book and we have eight more parts.
Looking forward to the Part 2
All posts related to "Learning Python by Mark Lutz"
Source Code@GitHub (exercises of this book)
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
Chapter 2: How Python Runs Programs
This chapter introduces you a needed theoretical overview of Python runtime (interpreter) and Python bytecode. The execution of the program is explained in two viewpoints - programmer's view and Python's view. The programmers' view is what code to be written following the language constructs generating source code and Python's view is how to execute the program converting source code to actual functionality (the output of programmer view is input to Python's view). The chapter offers execution model variations (different runtime models - CPython, Jython, Stackless, PyPy) and optimization tools (Psyco JIT, Shed Skin, Cthyon). This chapter is wonderfully written and there will be some learning to everyone. I thoroughly enjoyed the content :-). Kudos to the author for covering a variety of insights.
Chapter 3: How You Run Programs
I need to start with a warning. This chapter has so much information and ways to run your code like "from the command line", "interactive", "IDLE" and "IDE". I personally suggest that we should try all the methods at least once and choose one of the methods. I find IDE convenient. Yes, I do use PyCharm community edition. On the good side, the chapter introduces modules, importing, namespaces, module reloads which is quite interesting. Good round up of exercises at the end. I do not want to bog you down with a lot of details. One little advice I have for you is to take breaks while reading this chapter and be prepared for a long haul. Without the break, I feel this chapter is little tough to complete and might appear daunting (and might be demotivating to complete). The good thing about such details are completeness
BTW, with this, we complete the first part of the book and we have eight more parts.
Looking forward to the Part 2
All posts related to "Learning Python by Mark Lutz"
Source Code@GitHub (exercises of this book)
Friendly Note: I am posting the images and links from the publisher's website. I am not an affiliate and I do not get paid for writing this. If my journal is useful for someone to learn Python, I am more than happy :-)
30 December 2017
"Learning Python by Mark Lutz" - Reading Journal 1 [Intro and Chapter 1]
For next several months, I would be posting my experiences with Python more specifically the learning I am going to have from the book - "Learning Python by Mark Lutz". My first impression after reading the table of contents is very promising. It looks to me that it is one of the books that provide complete coverage of Python and exhaustive too. I am eager and yet at the same time little afraid because I never learned any programming language reading a book completely. Since it is massive in size containing 1500+ pages, I feel it is going to test my consistency. And that is one of the reasons why I want to write my reading journal.
The rest of the post contains what I learned from the chapter 1 (Initially I thought I would write journal of first three chapters. But I could not do it due to merits and the amount of content in this chapter)Chapter 1: A Python Q & A Session
The book starts with a bang providing enough material and motivation as to why someone should invest time learning Python and reading/working-out this book. This chapter provides an introduction to Python in the form of question and answer. These are kind of questions that were eating my mind and wanting an answer because the websites or courses talk only on the language but this book seems to address the gap as to "why". I also feel that the author has set up an important tone - question everything when you learn. You will find answers to the following questions
- Why people use Python?
- Is Python scripting language?
- Is there any downside of Python?
- Who uses Python?
- What can I do with Python
- How is Python developed and supported?
- What are its technical strengths?
- How Python stacks up to other languages?
This chapter gives deeper insights with solid reasonings and you will understand what you will get by learning Python and what is the amount of knowledge that you will get by reading this book - "Learning Python by Mark Lutz"
Needless to say, I am all excited to continue to learn Python :-)
29 December 2017
Simple ProcMon - Putting all things together
I have written few posts on process management in Python - fork, exec, wait, and exit. These are exactly same Python APIs around system APIs provided by Linux/Unix/POSIX. In this post, I am going to talk about putting things together and create a simple process monitor.
Functionality of Simple Process Monitor
- Have the list of processes that need to be monitored in the INI file. Let us call this configuration
- Load the configuration file
- Start the process
- Exec the new program
- Loop #3 and #4 until all the processes are loaded
- Monitor the process (wait). A simple call to "wait" would listen for a child to exit.
- When a child dies, handle it either by restarting the process again or do nothing (depending on how it is configured).
- Go back to #6 and continue the monitoring
It is going to tough to post all the code here. Refer my GITHub for the code. Feel free to extend or write tests
Experience: It is another personal experience on higher productivity claim of Python. I wrote the code in a couple of hours and spent around 2 hours on refactoring. Given my (lack of) experience in Python, Python seems to fulfill its promise.
25 December 2017
Process Management in Python - os._exit()
This is a continuation of series of posts on Process management in Python. Read this, this and this before continuing further. In this post, we are going to see how os._exit works and how it is related to "wait".
os._exit when invoked, the process that is calling it terminates immediately without doing any clean-ups (however system.exit() can be handled by the Python program, a much safer/clean way). The parent process receives the exit status when the parent process calls "wait" or "waitpid. os._exit calls _exit of OS
The following code demonstrates it. Beware, os._exit exits the process abruptly.
os._exit when invoked, the process that is calling it terminates immediately without doing any clean-ups (however system.exit() can be handled by the Python program, a much safer/clean way). The parent process receives the exit status when the parent process calls "wait" or "waitpid. os._exit calls _exit of OS
The following code demonstrates it. Beware, os._exit exits the process abruptly.
For more information on exit and _exit refer - https://en.wikipedia.org/wiki/Exit_(system_call)
Refer the Code in GIT Hub
Here is the code in Python (being Python, it is self-explanatory :-))
24 December 2017
Process Management in Python - os.wait()
This is a continuation of series of posts on Process management in Python. Read this and this before continuing further. In this post, we are going to see
- How the parent process can get the status of its child after the child has exited using "os.wait"
- What happens to the child processes after they exit but the parent is still alive and did not get the status (defunct - meaning that userspace is cleared but a small about of information in kernel space is retained so as to give the information when the parent requests the status which may potentially lead to inability to create new processes)
Getting the status of the child processes is simple. Just call os.wait() to get status of any child processes or waitpid to get status of a specific process. Note, this is blocking call meaning that the parent (thread) waits here until the child is exited/terminated.
For more information on wait/waitpid, refer - https://en.wikipedia.org/wiki/Wait_(system_call)
Refer the Code in GIT Hub
For more information on wait/waitpid, refer - https://en.wikipedia.org/wiki/Wait_(system_call)
Refer the Code in GIT Hub
Here is the code in Python (being Python, it is self-explanatory :-))
23 December 2017
Process Management in Python - os.exec
This is continuation of the previous post - Process Management in Python - os.fork()
In Linux, running a command from the shell is a two-step process. The shell first creates a process using fork (posted earlier) and overlays a new program using "exec". For example, when you want to run the command "ls" from the shell - the shell forks a copy of its own and immediately loads the binary of "ls" and starts the execution again.
Refer https://en.wikipedia.org/wiki/Exec_(system_call) for more details.
Beware, you cannot find a function exec() but rather it is a family of functions with names such as - execl, execle, execlp, execv. The functions are almost same and they differ only in parameters that are being passed. I have used one such functions in the following code. When you run this code, you should see a directory listing - the current process upon the successful calling of exec, loads "ls" and executes it. Once "ls" is executed, it exits (like it normally used to do)
As an experiment, you can do fork to create a child process and in the child process execution flow, you can overlay a new program.
Refer the Code in GIT Hub
Try running this script from Linux shell and see the output. Do not forget to share, like, comment if you like this post :-)
22 December 2017
Process Management in Python - os.fork()
Inspired by https://pymotw.com/3/signal/index.html, I thought of exploring os package in Python. The next few posts would be on process management and how to do it in Python. I would be showing you the code that is tiny. The goal is to provide basic code and I leave the improvision to you.
There are four important system calls - fork, exec, wait and exit that are related to process management. Interestingly Python provides equivalent APIs as a part of os package so that you can do a lot of system programming (and use it in a cool way). In this post, let us see some code that uses "os.fork" to create a new process.
os.fork() - creates a new process (often called as parent-child processes). The following code has enough comments and some explanation embedded as comments. Suggest you read the code and run it in Linux box.
Refer the Code in GIT Hub
Refer the Code in GIT Hub
If you want to know more about fork, refer - https://en.wikipedia.org/wiki/Fork_(system_call)
Share, comment and contribute if you like this post :-)
21 December 2017
Alarm and Signal in Python
Continuation to my previous post in Signals in Python. Again the credits go to Python Module of the week. The following code shows how easier it is to work with Python. This simple script registers for an alarm using SIGALRM which is configured to fire after "n" seconds. After "n" seconds, the handler function gets called.
In this code, I set alarm once as a part of main control flow and register again in the alarm handler. This program does not exit unless one kills the process or stops the execution of the program. (Python code seems to be more beautiful)
20 December 2017
Signal Handling in Python
If you are system programmer, you would have heard about signals and probably would have done lots of coding using signal. It might also be a second nature to you. But when you started to get your hands dirty with signals especially in C, it might have been quite involved. Now moving to signal handling in Python
Recently (last week), there was a post from Python Module of the week on signals and I thought I would try it. Here is the code that does some signal handling. You might want to check the full post (BTW, it is very interesting one). I feel that it easy to write code (and beautiful too) and I was able to do C-equivalent code in less than 30 minutes (which means that Python makes us productive). Here is the script that I wrote. You can find in GIT Hub and feel free to play around.
Credits - https://pymotw.com/3/signal/index.html
17 December 2017
"Python Crash Course by Eric Matthes" - Final Post and Review
If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.
This is going to be the final post on this book
Review Comments: I accidentally stumbled on this book when I was looking for the books on Python. As the name suggests, it met the purpose of offering the crash course in Python. I could see the chapters are shorter as that one can complete a chapter (or two) in a single sitting. and logically arranged. The code snippets (examples) and "try it yourself" offered a great insight into the programming language. If you are in a hurry to get yourself exposed to Python, grab a copy of this book and you should be making a lot of good progress in booting up in Python. I should also alarm you that this book does not cover the language and its features in great detail. If you are looking for a deeper coverage of each feature, there are other books.
This is going to be the final post on this book
Review Comments: I accidentally stumbled on this book when I was looking for the books on Python. As the name suggests, it met the purpose of offering the crash course in Python. I could see the chapters are shorter as that one can complete a chapter (or two) in a single sitting. and logically arranged. The code snippets (examples) and "try it yourself" offered a great insight into the programming language. If you are in a hurry to get yourself exposed to Python, grab a copy of this book and you should be making a lot of good progress in booting up in Python. I should also alarm you that this book does not cover the language and its features in great detail. If you are looking for a deeper coverage of each feature, there are other books.
I have solved all the exercises in GitHub. I do not intend to solve the projects now.
Ratings: I would rate this book a 4.5 Stars.
Recommendation: Apt for beginners of Python (If someone is new to programming, they might feel left behind in later chapters as the book covers quite a lot of ground in every chapter or might need to spend more time referring the materials online). If you are new to programming, maybe a MOOC course on Python would be an excellent start.
You can find all posts related to this book - here
Next Goal:
It is time to learn Python little deeper using "Learning Python" by Mark Lurtz
Want to challenge yourself?
Do you want to take part in the challenge of completing "Learning Python" in two months? Add comments below.
13 December 2017
"Python Crash Course by Eric Matthes" - Code Journal 2
If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.
Today's update:
Today (13-Dec-17, coded from 6am to 7.45am), I committed the coding solutions for Chapter 8. While solving the exercises, I realized that how easy and lovely is Python. When people say that Python is highly expressive, I did not relate to it. Now, I can :-). The amount of features that you can build with the amount of code is no way related. You will end up writing lesser code (less code means less time to develop means high productivity. Less code means fewer bugs which leads to high quality). If you want to experience it, try reading Chapter 8 and try solving examples. Lists, dictionaries along with various ways of using functions, passing arguments, passing parameters dynamically, passing a variable number of arguments are cool features of Python. Functions in Python is very powerful and yet flexible (I urge you to experience it by yourself)
Solutions to Chapter 8 can be found in GIT Hub Repository. View it and Share it
Today's update:
Today (13-Dec-17, coded from 6am to 7.45am), I committed the coding solutions for Chapter 8. While solving the exercises, I realized that how easy and lovely is Python. When people say that Python is highly expressive, I did not relate to it. Now, I can :-). The amount of features that you can build with the amount of code is no way related. You will end up writing lesser code (less code means less time to develop means high productivity. Less code means fewer bugs which leads to high quality). If you want to experience it, try reading Chapter 8 and try solving examples. Lists, dictionaries along with various ways of using functions, passing arguments, passing parameters dynamically, passing a variable number of arguments are cool features of Python. Functions in Python is very powerful and yet flexible (I urge you to experience it by yourself)
Do not underestimate Python and this book (because it is a crash course). Solving some of the exercises can be very involved and serves the purpose. I would give 5/5 for the exercises in this chapter. Great selection of exercises. Kudos to the author
Solutions to Chapter 8 can be found in GIT Hub Repository. View it and Share it
Want to contribute/collaborate?
If you want to contribute, you can clone the repository, create a branch and give me a pull request. If you want to know how to collaborate, email/call me. Together, we can make things better.
If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-).
12 December 2017
"Python Crash Course by Eric Matthes" - Code Journal 1
If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.
I am archiving all the code that I have written so far in GIT. Just in case if you want to see it live, check this out - https://github.com/grabyourfreedom/pythoncrashcourse. I have committed all the code that I have written till chapter 5. I will keep working on it - fix bugs, add comments, refactor and add solutions to more exercises. For next few days, I will work on the code until chapter 11 and start reading the other chapters from Saturday (for more posts and code). The code journal posts are likely to be short as I am planning to post only updates here and commit the code to GIT hub.
It is very exciting to ramp in a language - reading, coding, and sharing.
Want to contribute/collaborate?
If you want to contribute, you can clone the repository, create a branch and give me a pull request.
If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-).
11 December 2017
"Python Crash Course by Eric Matthes" - Reading Journal 4
If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.
This post gives an overview of what I learned in Chapters 10 and 11.
It looks to me that the last few chapters are really informative. This chapter didn't disappoint me. The first part talks about file operations - reading a file, writing to a file, appending to a file with few variations. The second part talks about handling/managing errors using exceptions (try, except and else). As a bonus, the chapter covers storing data using JSON module and at the end talks about code refactoring. Overall it is written well and does the job.
The next set of posts from me would be code journal. I will try to write a couple of posts sharing the coding exercises. With this, I concluded the basics of Python and I am excited to start the projects :-)
If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-).
This post gives an overview of what I learned in Chapters 10 and 11.
Chapter 10: Files and Exceptions
It looks to me that the last few chapters are really informative. This chapter didn't disappoint me. The first part talks about file operations - reading a file, writing to a file, appending to a file with few variations. The second part talks about handling/managing errors using exceptions (try, except and else). As a bonus, the chapter covers storing data using JSON module and at the end talks about code refactoring. Overall it is written well and does the job.
Chapter 11: Testing Your Code
This chapter seems to be very easy and yet at the same time very informative. It is great to see a book that boots up someone in a language (programming) talks about "testing the code". I feel that it makes a lot of difference in developer's life (others too) when we test our own code using automated unit tests. This chapter talks about testing your functions and classes using Python's unittest module with cool examples. And the side effect, it kindles the interest to explore further on creating automated tests too. Great job by the author
This chapter seems to be very easy and yet at the same time very informative. It is great to see a book that boots up someone in a language (programming) talks about "testing the code". I feel that it makes a lot of difference in developer's life (others too) when we test our own code using automated unit tests. This chapter talks about testing your functions and classes using Python's unittest module with cool examples. And the side effect, it kindles the interest to explore further on creating automated tests too. Great job by the author
The next set of posts from me would be code journal. I will try to write a couple of posts sharing the coding exercises. With this, I concluded the basics of Python and I am excited to start the projects :-)
If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-).
10 December 2017
"Python Crash Course by Eric Matthes" - Reading Journal 3
If you are new to Python and want to quickly ramp-up to become no non-sense developer in Python, you might want to read this post, these posts that are related to this book and probably all of these posts to become Python Super Star.
This post gives an overview of Chapters 7, 8 and 9
Chapter 7: User Inputs and while Loops
This chapter covers how to get input from the user, how to convert it to numerical values if you need it. It covers while loop, how to exit from the loop using flag, break, continue and how to avoid infinite loops. It gives a couple of examples of when and how to use while loops with lists and dictionaries. This chapter is extremely light for a developer and might be interesting to someone who is new to programming. You should complete this in less than 30 minutes including the exercises.
Chapter 8: Functions
The chapter covers quite a lot of ground with functions, modules and a bit on PEP8 styling guidelines with respect to functions. You will see how to define a function, without and with parameters, returning value, keyword argument, optional values, default values for parameters, passing a variable number of arguments, passing a variable number of arguments with keywords, importing a module, importing a function from a module, importing all the functions from a modules and aliases for module/functions with sufficient examples. The chapter closes with the styling guidelines from PEP8. An awesome chapter and I really liked this chapter. This chapter might take a little longer including exercises and reflection. It is best to pause here for some time to reflect to ensure you got everything. After completing this chapter, you will really feel that Python is powerful. Kudos to the author for giving us a wonderful chapter.
Chapter 9: Classes
Like the previous chapter, this chapter too covers very interesting paradigm of Object Orientation using classes and objects. If someone is new to programming, I recommend for a slow reading solving all the exercises and trying out all the examples. It is worth the effort. Ensure that you understand the essence of the chapter (classes, objects in OO paradigm) before moving further. If you already know another OO language like C++ or Java, it should be a cakewalk for you. This chapter talks about creating classes, __init__ method, self, creating objects, accessing attributes, calling methods of the objects, subclassing/inheritance, overriding, importing classes and styling of classes. Another wonderful chapter with real-world examples.
If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). Together, let us transform ourselves.
This post gives an overview of Chapters 7, 8 and 9
Chapter 7: User Inputs and while Loops
This chapter covers how to get input from the user, how to convert it to numerical values if you need it. It covers while loop, how to exit from the loop using flag, break, continue and how to avoid infinite loops. It gives a couple of examples of when and how to use while loops with lists and dictionaries. This chapter is extremely light for a developer and might be interesting to someone who is new to programming. You should complete this in less than 30 minutes including the exercises.The chapter covers quite a lot of ground with functions, modules and a bit on PEP8 styling guidelines with respect to functions. You will see how to define a function, without and with parameters, returning value, keyword argument, optional values, default values for parameters, passing a variable number of arguments, passing a variable number of arguments with keywords, importing a module, importing a function from a module, importing all the functions from a modules and aliases for module/functions with sufficient examples. The chapter closes with the styling guidelines from PEP8. An awesome chapter and I really liked this chapter. This chapter might take a little longer including exercises and reflection. It is best to pause here for some time to reflect to ensure you got everything. After completing this chapter, you will really feel that Python is powerful. Kudos to the author for giving us a wonderful chapter.
Chapter 9: Classes
Like the previous chapter, this chapter too covers very interesting paradigm of Object Orientation using classes and objects. If someone is new to programming, I recommend for a slow reading solving all the exercises and trying out all the examples. It is worth the effort. Ensure that you understand the essence of the chapter (classes, objects in OO paradigm) before moving further. If you already know another OO language like C++ or Java, it should be a cakewalk for you. This chapter talks about creating classes, __init__ method, self, creating objects, accessing attributes, calling methods of the objects, subclassing/inheritance, overriding, importing classes and styling of classes. Another wonderful chapter with real-world examples.
If you wish to join me in the journey of a lifelong student, add yourself to my blog list and I will not disappoint you :-). Together, let us transform ourselves.
Subscribe to:
Posts (Atom)
