We explain every GNU/Linux command by examples in this blog!

Theres a lots of people treated python as scripting language like bash, but I am going to tell you, python is real programming language. Python support callback like c/c++, and this feature is really God-like, because it is so simple to implement callback in python.

What is Callback?

In computer programming, a callback is executable code that is passed as an argument to other code. It allows a lower-level software layer to call a subroutine (or function) defined in a higher-level layer.

Quote from wikipedia

When we talk about callback, it usually in the form of function, therefore we also call it as callback function. We define our own algorithm in a callback function, and pass our function name as parameter to another function, where this function will callback our function for certain execution depends on the context.

Lets look at how we can apply callbacks in python. Lets look into how to define our own sorting function with callback technique.

Llist object support sorting by default, you can sort data in list as below:

What are we expect is ['r1','r3','r5','r13','r100','r103'] but end up sorted alphanumerically.

So, what should we do? create our own sorting function? how are we going to embed this sorting to the list object?

If you learn about algorithms before, you may understand that to perform sorting, we compare the every single value in a set, and thats how we sort it out. There are various sorting techniques, the simplest one is bubble sort.

You can use nested for loops to implement bubble sort, but here, you do NOT need to. You do not need create the entire sorting function yourself, you just need to define your own compare algorithms into callback function and pass it’s name to sort(), and python will sort accordingly for you.

To define a compare function for sort(), you must follow certain pattern.
1. Compare function must take TWO param: x and y,
2. It should return positive number if x > y, return negative number if x< y and return 0 if they are equal for Ascending sort.

So this is callback, the sort function will now call your compare callback in the sorting algorithm instead of the default one.

P.S. I always having difficulties to explain programming, my wish is to introduce callbacks for those who are learning python. Hope that this is useful for you.

FYI: In case you are curious why my python's prompt is so funny, I am using ipython, an Enhanced Python Shell.

Ok so am i allowed to just declare I LOVE YOUR FILMS!!!! I will be as a significant cooling fan! (#(: I actually hVe learned a great deal of about consuming caution if my dolls(#(: can you generate a video of some tips on for instance, takin care e them and…. like…. things like. to guide you in emergencies! (#(: thanks a lot EVA!

Many folks need to accessorize and shield their telephone
so it is an excellent market. Example (Resident Evil Motif, Call Of
Duty yada yada).Click on Install.Go to home menu. JailbreakMe works with the iOS
3.1.2 or later.