Truth, Computing and Fail

  • Home
  • About

Democracy and freedom: We don’t deserve it

anomit | November 23, 2008

Yes, you heard it right. We Indians don’t deserve it. Certainly not. When you don’t recognize the value of something you already have, you would rather not have it.

Let’s see what democracy would mean in layman terms. Fuck legal jargon.

    1. As a citizen of the country, you have every right to mind your own business, however warped it might be as long as you are not flipping out and killing someone.

    2. As a direct consequence, you are not expected to be dicking around dictating terms to others.

There we go. We can spot the problems already. Very obviously, you are not supposed to mind your own business. The State is watching over you. There are countless such obstacles you are facing in your day-to-day life. But the flavor of today’s post is night life, as I think I am in a better position to comment on things that I witness firsthand. What does common sense dictate? You are in a free country. You are free to move anywhere as long it is not some private territory and it does not matter whatever time of the day(or night) it is. Having said that, our benevolent authorities have made it sure you don’t have such peace of mind. How else would they remind you that they too exist, even though their sole purpose is to fuck you up. “Whoa! Hold on,”, you say, “I’m not cutting down anyone’s limbs. I’m just having a jolly good time”. Sure you are innocent. But some people just won’t have it.

“Student nuisance in Manipal will not be tolerated,” said the SP when contacted

…and what kind of nuisance would that be? That’s a bummer, you dork. You were enjoying yourself. That’s sure to be classified as nuisance. We have zeroed in on the problem, finally. Hope you are still with me.

This is a deep seated problem in the general Indian psyche and no wonder it propagates all the way up to the bureaucracy and administration. We have self proclaimed religious Godfathers, outfits that are somehow holding off the immoral apocalypse and above all of them, The Executive who are here to dictate terms on how you are to lead your life. This is the hallmark of Indian society. Even though there might be something that doesn’t affect them, people will always have their own judgment ready and more often that not, will see to it that you conform to it. Be different and be ready to be ridiculed and jeered at in this nation. Coming back to Manipal, this is a town full of students and the dynamics are quite different from, say, a colony of pensioners. Also, what could be the justification behind closing shops at 11:30 PM, regardless of what place it is in? None, as we would have it. I don’t think I need to further bring the achievements of our elite Police Force into the picture. They have been a complete failure at protecting the citizens of this country and are quite shamelessly open about this fact. There are fucking huge intelligence failures at the State level. What we have as a result are bomb blasts almost every other day. So what were the police doing? Oh, they were busy curbing the “student nuisance” and also seeing to it that our morality isn’t destroyed at the same time.

The whole of the police force in India is a shameful bloat on the nation, unlike the motivated soldiers in our Army, Navy and Air Force. The reason is not too hard to find out. It still carries the Victorian legacy on its shoulders. It still functions on the same principles from that era when it was used to intimidate the common person rather than protecting and helping them out. That mindset has surely carried over even into the 21st Century. When was the last time that you were to a police station and experienced cordial behavior, unless you pulled some strings, that is. I lost my Airtel SIM card once and went to the one and only police station in Manipal to lodge an FIR since it was a serious matter and I had no intention of getting involved with the SIM card falling in wrong hands. The officer who was supposed to help me out with it rather displayed an attitude as if I had already committed a crime by losing the SIM card and lectured me half an hour straight on some rules I was not in the mood to listen to. Needless to say the FIR wasn’t lodged even though I had the necessary documents with me. Thankfully, the Airtel guys had a really hassle free way of issuing a duplicate SIM card that would block the original one. I wonder where this display of zealous enthusiasm to maintain “an iron hand” over law and order was at that time . I’m not sure if the founding fathers of this country would have had this kind of a situation in mind, where people are harassed and prosecuted just for being outdoors at night. We know we don’t have much hope when the CM of Delhi herself thinks venturing out at 3 AM is a bad idea and too “adventurous” for a lady, even thought it may well be a part of her job.

Fuck whatever TATA Tea has to say. Democracy isn’t all about casting your vote. Rather it’s about knowing one’s rights and having a strong sense of self-worth. Anyway, if there is something whose worth you don’t realize, it won’t be with you for too long.

Comments
7 Comments »
Categories
Uncategorized
Comments rss Comments rss
Trackback Trackback

Parsing XML in Python

anomit | November 16, 2008

I started off with BeautifulSoup for a certain project that needs to construct database queries out of XML. I was almost done with this component when I discovered much to my chagrin that BeautifulSoup does not respect the case of the strings in the tag name. For eg some text would yield the name of the tag as ‘foobar’. I had to find some way to replace the code base within a short time.
I quickly went through some of my starred items in Google Reader. One of the interesting finds was using lxml from the IBM developer works pages. One of the examples in that page seemed very similar to using a SAX parser. I wasn’t quite interested at that moment to learn a third party library from scratch, so I decided to go for the xml.sax package already provided by default. A tutorial and reading through a couple of pages from the book ‘Python and XML’ later, I managed to get it right.

Basically, an SAX parser is event driven, and you can define functions that can be described like event handlers in JAVA which act upon those events. These events include encountering the opening or closing of an XML text node, an XML element node etc. The JAVA implementation of SAX defined interfaces for the handlers. SAX for one thing, doesn’t have a formal specification as yet and since Python doesn’t support interfaces, it included four classes in xml.sax.handler. You can read about them in the python docs. From the docs:

Handler implementations should inherit from the base classes provided in the module xml.sax.handler, so that all methods get default implementations.

The one we will be using the most is the class ContentHandler. The handler for our own XML format will inherit it. We override functions implemented in ContentHandler to customize them to our own needs. Some of the important functions are:

startElement(name,attrs): This is called by the parser when it encounters the start of an element. name holds the name of the element and attr holds the attributes.

endElement(name): Called by the parser when it encounters the end of an element.

character(content): Returns chunks of character data when found. The character data may be included in a single chunk or split into multiple chunks. It’s advisable to use flags rather than relying on the former assumption.

Since a SAX parser is a stream parser and doesn’t build an in-memory tree, you can’t backtrack in the tree and nodes don’t have the usual child-parent relationship found in DOM style parsers. Flags are used to track what element the parser is currently in and take appropriate actions. There is a caveat here. If you are working on a tree with a large depth, it can be really frustrating and painful to manage a lot of flags. The one I am working on can have a maximum depth of 5, but it would rarely exceed 4. So it wasn’t a big deal for me to handle that many flags.

The basic outline of a program that makes use of SAX in Python would be like
#####################################################

from xml.sax.handler import ContentHandler
from xml.sax import make_parser

class CustomHandler(ContentHandler):
	def __init__(self):
		#initialize flags and other data structures if needed
	def startElement(self,name,attrs):
		#set flags, get value of attributes etc
	def endElement(self,name):
		#clear flags etc
	def character(self,ch):
		#copy character data to any data structure if needed
ch=CustomHandler()
saxparser=make_parser()
saxparser.setContentHandler(ch)
saxparser.parse(some_file_stream)

########################################################

PS: I am still stuck with Python 2.5.2. I’m trying to keep pace by reading the changes in 2.6. I am counting on Harsh to bail me out when the need arises :p

Comments
4 Comments »
Categories
Coding
Tags
python, xml
Comments rss Comments rss
Trackback Trackback

What’s in

  • Symlinks in a libfs virtual file system: The Pains
  • Small rant on the FUSE API reference
  • Kernel module debugging: a simple technique
  • Vim/Cscope quickie
  • PyCon India or Code Jam?

Blogroll

  • Akshay Kothari
  • Ankur Shrivastav (OS)
  • Ankur Sinha
  • Harsh J
  • Hullap
  • LUG manipal
  • Swap

Tags

aircrack airfail airtel assembly blues build c Coding college country cryptography dean faculty file systems fuckery gnuplot hacking India kernel linux mangalore manipal mpd music NASM plugin plugins politicians pub culture python rant rock sam scheduler simulation SSFNet stupidity supernatural suppression syscall syscalls unix vim xchat xml

Archives

  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • January 2009
  • November 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • October 2007
  • September 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007

License

Creative Commons License
This work by Anomit Ghosh is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 India License.
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox