geeklog: suppress line feed in consecutive print statements in python

It might be something that the whole world already knows but I am excited because I just discovered it :). And since programming in python is not something that one learns by first reading a book from cover to cover (at least I did not :P) and then sitting to write code, I presume many may have missed this one little thing like I (and my colleague) did. I mean, I took it forgranted that a print statement will always start with a new line until today. Okay coming to the point without further rambling. If I have a function like this:

>>> # Code Snippet One

>>> def print_stupid_stuff():

...    print 1, 'stupid'

...    worthless_var = 42 + 0

...    print 'stuff'

then I get something like this when I run it:

>>> print_stupid_stuff()

1, stupid

stuff

However if I have something like:

>>> #Code Snippet Two

>>> def print_stupid_stuff():

...    print 1, 'stupid',

...    worthless_var = 42 + 0

...    print 'stuff'

The output will be :

>>> print_stupid_stuff()

1 stupid stuff

So if you were not able to spot the difference between the two code snippets, there is an extra trailing comma at the end of the first print statement in Code Snippet Two. So a print statement does not prepend a line feed but appends it unless we have a trailing comma. Those who think that I wasted your time by writing a blog on such trivial a trick, I am not sorry :P. I just wanted to post some code on my blog, why did you read if you think that the post did not have anything significant to offer?

I am posting something on my blog after a long time, don't have anything more to say, but can't stop typing... typing typing abcdabcdabcd aarrrgghh ... thaueu eu et uaeu aeu, CAN'T eau ua CONTROL etu teu MY fiififi FINGERS ssssssss THEY aaaaa WANT ttttt TO oototott TYPE eemmememmmemo MORE etenuteutu

:D, on a serious note, Adios !

Indiblogger Meet Delhi

I am just back from a "Blogger's Meet" organized by indiblogger.in at Hotel Park, Connaught Place, New Delhi. The event showed the hardwork put in by the indiblogger team. Turn out was good, people enjoyed to the fullest. In one sentence I can describe it as a perfect event comprising of an unbelievable yet real mind reading magic show by @karansinghmagic, a not so interesting (yet necessary) ad campaign by the sponsors and a debate and quiz anchored by an impressive and talented TV personality known as @rajivmakhni where they rained smartphones, tablets and usb drives as gifts and prizes.

The crowd consisted of all sorts of bloggers (food, tech, photography etc) from Delhi and adjoining areas. The views expressed during a short debate on security concerning mobile devices exhibited the sorry state of tech awareness amongst Indians on the whole. I mean if bloggers, who obviously are at least computer literate can be scared of and believe in tell tales about mobile phones being hacked and data being stolen under most wierd conditions (eg not connected to any data network) or viruses infecting their devices, privacy being invaded then, Probability save the country. I tried and put forward my opinion on this issue which was : Data that people are generally scared of falling in the wrong hands (eg personal info like birth date, phone numbers etc) has already been distributed willingly by us so many times, not just in the virtual world but in the physical world too (to educational institutes, banks, government services etc) which has most likely been stored electronically that for somebody striving hard enough to obtain it, it would be a piece of cake. And being oblivious to basic knowledge essential for using a device safely will only give rise to a kind of PEBKAC (Problem Exists Between Keyboard and Chair - i.e USER) and if such users fall prey to petty attempts of crackers ( != hackers) NO ONE ELSE IS RESPONSIBLE. The mantra recited in many superhero flicks which came to my mind after I was done speaking seemed very apt : With great power comes great responsibility.

On the whole had an awesome weekend, enjoyed, met a lot of new faces and had free dinner at a 5 star hotel :)

'OPEN' social problems

A problem in any field of science that hasn't been solved till this date is termed as an open problem - open for all interested persons and parties to wrack their brains on. Yup, here as another post on social problem, opening with a reference to science - ki kara geekism control nahi honda :P

So what do I exactly mean by OPEN social problems? Any and every problem, issue or situation  that people, politicians, celebrities and media-wale pick from time to time for a discussion, debate or a deliberate discourse, in search of an opportunity to express their views and thwart the opponent's opinion thereby establishing or consolidating their intellectual and oratorical supremacy (except media-wale who's lives thrive off the spiced up drama) without ever reaching a strong, sustainable, sensible solution to the problem which can be implemented in a real world scenario for ever being able to curb it.

Pretty cool for a definition, don't you think? Well 16 years of formal education will convert even the dumbest of idiots into definition inventing ninjas provided they refuse to ever or resolve to never mug up and remember the exact contents of their petty text books.

Coming back to the central idea of this post, such discourses can be witnessed in diverse locations depending upon the people involved in them. Eg neighbours at the local tea stall, politicians on a panel discussion on a news channel, celebrities in reality shows and relatives at occasional family gatherings. Every once in a while, motivated and passionate individuals pick an issue close to their heart and try their level best to sell their version of the solution, or at least spread awareness, though to an unbiased observer it might look like an unparallelled historic revolution turned melodramatic publicity campaign in short a magnanimous waste of time. And its not because the leaders lack dedication but because of something that's known since Shakespearean age and media tries to en-cash everyday - "The mob is fickle minded". If that's not the case then tell me why corruption continues to survive and thrive after the greatest non-violent war against it in the history of our nation?(link) Its easy to create a buzz and get people excited but the effect wears off and that, is a damn reality.

A well known celebrity has started yet another Talk Show aiming to tackle one problem every episode. Now this guy, is executing a commendable idea and doing a great job. The show has revved up even the laziest of Indian minds. But being an engineer my brain is trained to be skeptical, test the phenomenon for its chances of success and here I sense more futility than fertility. Reason - we are still doing what we always do and hence are best at it - talk and show - the actual work takes a back seat as usual.

What you don't believe that we concentrate more on showbiz? Here are some examples: ask existing (or would - be engineers) graduated (-ed +ing)  from an average Indian college and you would find that they spent more time bringing the design and layout of the report upto their guides expected definition of perfection instead of the actual content of the report (unless they knew \LaTeX ).  This is because our brains are trained to fall for better looking packages instead of their contents. Why do you think ads about every other commodity excitedly mention "Our product is available in an ATTRACTIVE NEW PACK" when all we do with the pack is throw it in the bin (link). The question we need to ask ourselves is whether the extreme importance that we give to the blatant exhibition of sincerity and external perfection will ever solve actual problems?

The conclusion is: something somewhere has gone severely and insanely wrong and the situation will steeply worsen unless we do something sensible sometime soon. Blah blah blah, enough mumbo jumbo, until people actually act on the advice they are always ready to give away, probability knows that even this thing will turn out to be just another talk show and will effortlessly be pushed out of citizen's minds just like an old toy chucked out by a toddler upon the arrival of a new one. And had we already been doing just that, there would have been no need of such an elaborate display of concern - because there would have been no situation to get too concerned about.

And since I know that expecting people to follow their own advice is like asking America to destroy all its nuclear war heads - I believe that there shall be no dramatic changes and that the world as we see it today, is here to stay. Satyamev Jayate !

B.Tech to be tech - engineering to engineer

The four year course of engineering in computer science that I was pursuing has come to its close. I attended the concluding ceremony (samapan samaroh) today in the afternoon. On a lighter note, it was a journey from a free lunch (for students coming for admission interview) to free supper (after the concluding ceremony) by the college. At the ceremony, I received two awards - one for being the president of Linux Club and another for "best summer training" and a provisional degree . Heck! I am officially an engineer now!

The last four years ...  Don't worry it wont be sentimental, just a short summary with a pinch of nostalgia. The last four years of engineering have been a blend of varied things including self-learning and exploration outside classroom, regular showoff (in a good, geeky way) in class, frequent bursts of pure fun during bunks, sheer ignorance, boredom, laziness and restlessness amidst exams, unprecedented one-night-stand preparation < 24 hrs before every exam, utterly unbelievable pranks in hostel, unintentional and non premeditated chivalrous flattery flirting, sparse timely submission of select assignments, totally unprepared appearing for viva and practicals, geeky hack nights with the geeks of ALiAS (Linux club), trips to a few meetups, conferences and events concerning FOSS or Linux, invitations to drinking and smoking parties that I always forgot to attend, stroll (mostly solitary) around the campus after dinner almost every evening, totally unpredictable sleep/wake cycles, regular hunt for audio visual entertainment material (movies) in hostel ... the list has no end!

Apart from the intended curriculum my fours years of engineering have undeniably taught me some unintended yet useful set of skills. One is the Art of Waiting :taught throughout the campus at places like  cafeteria and general store counters, ATM, before project presentations & placement interviews, for meeting higher authorities and these ultimately came in handy during the very few ultra boring lectures. Another one is more versatile skill of jugad - the ability to instantaneously and successfully derive, device and deploy a solution for any problem with whatever limited resources available at hand (self incriminating examples withheld).

A process, however interesting or boring, once started, it eventually ends. So has my engineering course. Now on a slightly sentimental note, I know that life will move on and the circle of my acquaintances will constantly keep changing, evolving and growing but the place which had been created in my mind by the faculties cum friends, friends cum ex - batch mates / juniors / linux club members for themselves, can't and hence shall not be overwritten - they are ROM now.

As the course for engineering is over, I hope and expect myself to begin with some engineering soon. Tech Anecdotes shall have more posts, perhaps with an increased frequency and from a new perspective but the source shall be the same blob of neurons, as long as they are is safely housed inside my skull. Now that I am a B.Tech I shall try and be tech :).

A Solution To Commutation Woes

Ask an average resident of a modern city - "what is it that you dislike most about your city" and the answer will most certainly include "traffic and commutation woes". The population density of the cities is growing at an alarming rate, more and more people are flooding in, in search of (seemingly) better - jobs, education, spouse (mostly husband) etc and seldom anyone retraces the path. The more the people more are vehicles - be it private or "bhade wali" (public). And the broadest of roads are, at times, not able to provide free passage to these vehicles and a commuter is subjected to the most frustrating of experiences - waiting indefinitely in a snailing, snoring, shrieking and farting traffic.

If observed from a broader perspective, the current situation, apart from being uncomfortable, is extremely expensive, both economically and environmentally. So here is an idea that sprouted in my mind and has been pondered upon for quite some time (an year or two), mostly while being stuck in one of those (seemingly) never ending road jams.

Bicycles, one of the most efficient machines ever created, have been around for nearly one and a half centuries but in past few years their usage has been reduced to means of commutation for the "fourth grade staffs" or as a mere source of entertainment by chlidren. The ever-expanding cities make it impossible to commute from one end to other on one of those. So I propose, a City Wide Bicycle Network as the solution to all commutation woes.

Taking the NCR (National Capital Region) for instance. The long distance commutation is taken care of by the excellent network of buses, local trains and most importantly Metro. The real problem is faced in traveling to and from the bus stand / metro station to the destination. The idea is to setup a cycle stand at every popular destination with heavy footfall and also at the bus stands and metro stations, which shall have a few hundred bicycles available, and parking capacity for a few more. An average commuter, upon getting-off at the nearest station shall walk into the cycle stand and get one issued for himself and cycle to his / her exact destination. There after the cycle can be returned at any of the stands around the city from where the commuter wishes to change his mode of transport.

Such a service can be readily made available to the public at a very reasonable cost of say, approximately a thousand INR a month (unlimited) or based upon usage (plus security) for an individual. Setting up the whole infrastructure on a complete city wide basis for a metropolitan city like NCR might cost a few hundred crores. And amongst the innumerable benefits that might come as a by-product will be - dramatic reduction in dependence on and consumption of petroleum, eradication of pollution due to vehicles, decrease in traffic jams and accidents which shall thus amount to enormous savings in terms of money, time and environment and help commuters live a long, healthy and peaceful life.