Skip to main content

Posts

Showing posts from June, 2013

cmd.Cmd module

Python has lots of surprises for it's lovers, one such pleasant one is the cmd.Cmd module .    A programmer might encounter tons of project where she might have to write a command line interpreter for his program to execute it. Typical undergrad lab. projects have tonnes of such project where one has to implement something, say for example Graph or a toy ticket reservation system. All these projects require the developer to create a command terminal which will prompt the user to write a command from some predefined set of them and then print the result in the terminal. Python provides a brilliant solution to such repreatative task in the form of a module cmd.Cmd. The best part is that the it gives the developer the freedom to do his implementation task independently to the command interpreter module. Cmd module offers tonnes of feature, some of them are -- command auto-completion auto help functions auto generated description of the command from the python docs. f...

Death by Puns : Networking Protocols

A TCP packet walks in to a bar and says “I want a beer”, barman says “you want a beer?” and TCP packet says “yes, a beer”. In high society, TCP is more welcome than UDP. At least it knows a proper handshake. A bunch of TCP packets go into a bar, until it’s overcrowded. The next day, half as many go in. A bunch of TCP packets walk into a bar. The bartender says, “Hang on just a second; I need to close the window.” When I try to send SYNs to chicks, I don’t get any ACKs. Just FINs and RSTs. IP packet with TTL=1 arrives at bar. Bartender: “Sorry can’t let you leave…and you don’t get any beer either…”. The worst part about token ring jokes is that if someone starts telling one while you are telling yours, all joking stops. The great thing about TCP jokes is that you always get them. The problem with TCP jokes is that people keep retelling them slower until you get them. I would tell some UDP jokes too but I ne...