What is a signal?
Software interrupts sent to the program to notify on significant event or request the program to run special sequence .
For example, the following command uses SIGHUP signal to request the program to reload it’s configuration
What is a daemon?
Except for nature spirit, a daemon is also a process running in the background, meaning it’s a non-interactive program. It’s detached from the terminal of an interactive user.
There is no easy way to identify which processes on the system are daemonas. It’s common to think that processes with ppid (parent pid) of 1 are daemons, but you can easily create in your terminal interactive process with ppid of 1, meaning not all processes with ppid 1 are daemons.
What is GIL?
GIL (Global interpreter Lock) is a mutex. Mutex is an mutual exclusion object used to prevent from two threads or more, to access the same piece of code. This piece of code also called ‘critical section’.
So GIL is Python’s way to ensure only one thread is running the code at any given time. It serializes the access to the interpreter and ensures that each thread gets exclusive access to the interpreter internals when running.
For Python beginners, the differences between lists and tuples might not be as clear as to those who already got some experience using them.
Let’s review the key differences between the two. hopefully, it will help you choose the right type in your code and understand that although this post called ‘lists vs. tuples’ there is no real match here. each type has his own use case.
Mutability talks about the capability of an object to change or alter. This is one of the noticeable difference between the two types.
First, let’s use list:
>>> my_list = [1,2,3]
>>> my_list = 9
>>> print my_list
[1, 2, 9]
Now let’s try the same on tuple:
A palindrome is a sequence of characters which reads the same backward or forward.
For example dad, mom, kayak, a santa at nasa, anna. Not palindromes: mario, luigi, ice cream.
There is more than one way in python to check whether given string is palindrome or not. Let’s have a look.
return my_str == my_str[::-1]
defiantly one of the shortest ways to do it.
[::-1] taking care of inverting the string and all is left is simply compare between the original to inverted string.
Slower than the first method:
return my_str == ''.join(reversed(my_str))
My least favorite but quite common (especially in other languages)
for i in xrange(0, len(my_str)/2):
if my_str[i] != my_str[len(my_str)-i-1]:
Q: How can I handle case-sensitive palindrome?
A: you can use upper() when comparing the reversed and the original strings.