Most people I have spoken to about python, do not believe in the object oriented capabilities of python. Python does not require you to always create a class like Java or C# but it is a language that is inherently object oriented. Like we say that “In Linux everything is a file”, in python, everything is an object. Even functions are objects and can be passed around. Python decorators pass around functions but that will be an article for some other time (and maybe a long one as well).
Python follows the Verb method of programming. The two ways of programming (Verb based and Noun based) are explained beautifully here. But let me brief it for you. Suppose the task is to take out the garbage, in the verb world you would do something like this Continue Reading →
This article came after a long hiatus from the previous one and I would like to apologize for that. I came across many neat things in python recently and am somewhat finding it overwhelming to master them all. Every time I learn something, there is something else that completely baffles me or at least intrigues me to solve problems differently. Hopefully writing this article would be comforting of some sort. In this article I am going to document some little capabilities available to python users to help them in their day to day adventures.
Python gives a powerful utility to create anonymous functions to users. These functions are not bound to any name (i.e they are anonymous, as already stated, by me ). Lambda functions are apparently well built into the core of python structure and support all possible optimizations and provide good performance. Let me just start off with a example so that my rants make sense.
>>g = lambda x: x**2
I come across a lot gems in python. Some are easy to understand, some require more time. The best way to understand them is by working with them and using them in programs. To make the understanding stronger you can write about them. I wanted to understand the yield command better so here it is.
To understand ‘yield’ you first have to understand generators, iterables and their difference.
Iterables are a pretty well-known concept. They are anything that you can iterate on. Remember in basic C you first had to find the length and then run a ‘for’ loop to find all the elements. Iterables you can directly iterate and access all the elements. Continue Reading →
These definitely have to be checked out.
ge. It basically gives you a programmable browser. It takes care of https, cookies and all the forms. It gives you immense power to Mechanize is an awesome packado a lot of things.
Imagine you have a browser that fills all the forms for you, submits them and process the response. Imagine doing it 1000 times or hey, a million times only limited by the processing power you have. Imagine spamming comments using this, I am not saying that you should, I am only saying you can. But most comments have captcha and limit on comment flooding anyway.
But this package can helps you do some managing if desired. It helps you access resources required, have custom filtering, provide custom services etc. Things you can probably do is make a separate archive of your emails, email contacts, alerts based on constraints etc. The most freakingly awesome thing you can do is write your own web crawler. Crawl through the web, index info, handle loops and maybe finally start your own search engine that kicks Google’s ass. Continue Reading →
I have watched a lot of anime from my childhood and continue to watch them even now. I read a lot of manga as well. If you don’t know what a manga is, this can help you. I clearly remember dragon ballz being my first anime immediately followed by naruto and a bunch of others. Now, I have watched so many, I have lost count.
But every time I started watching an anime my parents would start to whine
- They are such a waste of time.
- Are you still a kid to watch cartoons?
- If you stop watching them you might do better at exams.
- If you watch anymore the world will stop spinning.
- MY feet hurt because YOU are watching anime etc.
Every time they said that, I would always feel guilty and wonder, am I really wasting my time? Will I screw up my exams? What is the mystical connection between earth’s core and watching anime? As stated by me here, I always want to learn and keep learning from everything I do. So there was one important question I asked myself, what am I learning from anime? Here are some important ones.
1. One Piece – You have to rely on your ‘nakama’ (teammate), you can’t do everything alone
I am writing this article at 1am with droopy eyes and cannot guarantee its quality. But anyway, I came across design thinking in a special topic class I took in Spring 2013 called “Visual Interfaces for Mobile Design”. This was a really different and interesting course. It had zero importance to exams and by-hearting stuff. It was an very open-ended and fun class. It was a class where the amount of things you learnt totally depended on how much you wanted to learn. The prof had a given a bunch of topics we had to do a reading assignment on, and one of them was, as the heading says “Design Thinking”.
For this I had to read a paper (that unfortunately can’t be linked here) and watch this really good TED video. I have not completely understood what design thinking actually means or how to develop it. But I feel it is very important for all us to learn what design thinking is if we want to grow as an effective developer and really enjoy what we do.
Immutability is a very important concept that most of us might not know it explicitly. An immutable object cannot be modified after it has been created. Consider the following simple python code.
var = "hello"
var = "6"
gives an error
TypeError: 'str' object does not support item assignment
That is because ‘String’ is an immutable object it cannot be modified after creation. A compiler/interpreter stores the ‘String’ in an optimized format for easy and efficient use thus rendering them un-modifiable.
Why are immutable objects needed?
- A compiler/ interpreter does this to reduce complications and work efficiently.
- Immutable objects are inherently thread-safe
- Simpler to understand
- Offer good security
That is great, but why should I know about immutable objects?
Python has made programming an absolute pleasure for me. I simply love coding in python. The ease of programming and the importance given to programming logic than programming syntax is an absolute delight. I first learnt python from this tutorial. It is a great website to learn python, especially for the beginners. A more advanced one can be found here. Whenever someone asks me, how is it to code in python? I always remember this xkcd comic.
According to me (among the programming languages I know), python is the only true “high” level language. I mean, if programming languages took part in “Game of Thrones” python would be on Iron Throne the whole time uncontested. Continue Reading →
Stack Buffer Overflow is a very neat security vulnerability. I was fortunate enough to learn and work on it during my security course at NC State. It can be defined as an anomaly where a program overwrites the buffer allocated to it and writes into adjacent memory.
How can this be beneficial?
Well, you can potentially overwrite a return address and make it point to some malicious code. When the system returns to that address it executes the malicious code allowing an adversary to take control of your system.
Why would anyone want to do this?
Money, research, fun, your kung fu master ordered, some celestial being commanded, it could be anything.
How do you do it?
Well, to understand how to overflow a buffer you must know how stack works and for that, you must know where the stack is located. This is typical diagram of the system memory layout.