Thursday, July 14, 2016

Regular Expressions with Python: Examples of common functions

Regular Expressions are tools to filter and grab information from a heap of strings. Python has got a lot of toys to deal with it. The module "re". I am going to give you a quick ride through it. The ones that we use/gonna use the most.

So just immediately launch your favourite IDE and type "import re". Let's get started.

for the object r where r =, subject),

r.start() - Gives the start point where the match was found.
r.end() - Gives the end point where the match was found. - Returns the full matched string - Returns the matched string for the 1st group - Returns the matched string for the 2nd group

And so on....

Note : is same as

The number of groups available depends on the number of groups used in your pattern.


>>> regex = r"([a-zA-Z]+) (\d+)"
>>>, 'July 4')
<_sre.SRE_Match object at 0x0000000002E4D140>
>>> r =, 'July 4')
>>> r.end()
>>> r.start()
>>> 'July 4'[0:6]
'July 4'
>>> 'July 4'[0:5]
'July '
'July 4'

Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
IndexError: no such group


>>> r = re.findall(regex, 'July 4 August 10 Sept')
>>> r
[('July', '4'), ('August', '10')]

Same example with findall...observe how we got two results since there are two patterns in the string .

Noteworthy : If you are using groups with findall, then the result will be a list containing tuples as above.
But if you are just using single regex (no grouping), the result will be a list with strings .


>>> re.findall('\w+', 'July 4 August 10')
['July', '4', 'August', '10']


The finditer returns an iterator of re.MatchObjects.

>>> it = re.finditer('\w+', 'July 4 August 10')
>>> for i in it:
        print 'July 4 August 10'[i.start():i.end()]

>>> for i in it:


Tuesday, February 2, 2016

Rajasthan: The Best backpacking destination in India

Why Rajasthan?

  • Suitable for all size of plans . Week long , month long , or a day long.
  • Numerous popular cities to visit.
  • Shopper's paradise.
  • Best forts in India in one State.
  • Diversity - Greenery, Desert, Lakes, Urbanization or Tranquility. You will get it all.
  • Wildlife Sanctuaries
  • Heritage cities - Best for people who love cities with a history.
  • Food - A host of popular dishes to cherish. Vegetarians rejoice.
  • Transport - All options are available, abundant and safe. Trains. buses or airways.
  • Budget friendly - One can choose a budget fitting as he likes. Everyone can enjoy irrespective of his pocket strength.

The Plan


  Day 1
    Day 1
      Day 2 
   Day 3
   Day 4
   Day 5
   Day 6
Day 7

1.  Pune to Mumbai (Bandra Terminus) (via Bus) , Distance: 159 km

2.  Mumbai to Chittorgarh (via Train 22901 / UDZ SUPER FAST) Distance: 831 km

   Duration: One night stay in Chittorgarh

3.  Chittorgarh to Udaipur (via Passenger Train) , Distance: 117 km

   Duration:  Same day departure for Jodhpur

4.  Udaipur to Jodhpur (via State transport Bus) , Distance : 261 km

  Duration: Two night stay at Jodhpur

5.  Jodhpur to Jaisalmer (via Bus) , Distance : 285 km

 Duration: Two night stay at Jaisalmer (First night at Sam Sand Dunes)



Before you get excited about reaching Rajasthan , you must be aware that your Trip began as soon as you left your room. Ours started as soon as we left Pune and caught our bus to Mumbai. This was a good opportunity for me to spend some time in the City Of Dreams.Mumbai.  Our train was to leave at night from Bandra Terminus. So we ventured wherever our hearts took us.

Mumbai Special Thali

The largest fort in India - Chittorgarh Fort
Prakash Palace
Prakash Palace
Prakash Palace Ruins
Padmini Temple

Inside the fort:
  • 7 Gates
  • 2 Stambhas
  • 3 Palaces
  • 1 temple

Note>  Time needed to cover all points: Minimum 4 hours

What to do :
  • Arrive early in the morning and check-in to any hotel (should be closer to the fort) 
  • Hire an auto and visit the Fort. Take plenty of time to explore. It is huge enough for a full day.

Udaipur : The city of lakes

Although we spent just one day here, I would suggest, you should plan for at least 2 days (1 night halt), as this city has a lot to offer. I won't list them all. But for back packers with a short time, these location are the ones I would recommend as a "must visit".
  • City Palace
  • Lake Palace (Unfortunately, you can just enjoy view from a distance as tourists are no more allowed to visit it)
  • Lake Pichola

Note : 1) For all the above spots , the good thing is, you don't need to travel at different parts of the city. All are located around each other at walking distances.

2) Do not miss the evening light & sound show in City Palace (It's ticket are to be bought separately).

Lake Palace
City Palace

City Palace Light and Sound show
City Palace Evening Light Show

What to do:
    • Take a passenger train in the morning from Chittorgarh Station. It's about 3 hrs journey.
    • Visit your selected spots in Udaipur (Depends on how many days you have. There is a lot to see here). 
    • Watch the evening light and sound show in City Palace.
    • Shop on City palace road.
      Shops in Udaipur around City Palace
      Shops around City Palace Gate
    • Catch a night bus from City Bus Station for Jodhpur.

      Jodhpur : The Sun city

      Jodhpur is the second largest city in Rajasthan. So it is abound with markets, food and what not. This is where you stop to shop. We spent 2 days here. Most amazing looking fort I have ever seen. The Mehrangarh fort. It looks like a giant sitting on a mountain. 
      For shoppers, busiest market near Clock Tower. It's a must visit (women are going to love this).

      What to do :
      • Get a hotel near the Mehrangarh Fort (We stayed at Hotel Haveli ) and the room with a view of the fort. 
        Room in Hotel Haveli in Jodhpur
      • Go on a hike from your hotel to the fort. Explore all day.
      • At evening , visit the city market near the clock tower.
      • Try a variety of cuisines offered in road side hotels. The tea tastes awesome. I discovered a host of sweet dishes.
      • Have dinner at roof top with a view of the Mehrangarh Fort alive with lights. Most amazing view of any fort you have ever seen.

        Checkout at morning and leave for Jaisalmer via Bus. The buses are another thing to notice. The interiors are decorated to remind you of the culture and art of Rajasthan .


        Our final destination. The golden city of India. Jaisalmer . And it's crown jewel,
        Jaisalmer fort also known in other languages as Sonar Kella, Sone Ka Kila. Jaisalmer fort is the only fort in India where people still reside. It has around 5000 population. The fort is self sustaining . It has got everything you can imagine. Temples, Market, Food, post office. There is nothing like it in the whole world.
                                    I bet you must be thinking..When do we get to see some sand . Well....Its all sand here. The fort itself is build with Sand Stones. Even cooking utensils are made out of them . Also fossil stones are abundantly found which are used to make a variety of things. I leave you to discover all that by yourself.

        What to do :

          • You will reach Jaisalmer by afternoon. Have lunch.
          • Then book a trip and night stay in Sam Sand Dunes. Don't pay more than 2000Rs for one person.
          • Enjoy ride on Jeep over Sand Dunes. Enjoy the Thar desert. Explore yourself around.
          • At night, the camp comes alive. There is Rajasthani dance and music.

            Rajasthani Folk Song

              • Next day,come back to Jaisalmer city in the morning and check in to a hotel outside the fort, conveniently located at walking distance. (We stayed at 1st Gate hotel. The best hotel experiences of my life. Little overpriced but worth every penny.)
              • Go to explore the fort. Visit the market around. (I explored the fort at least 3 times...The fort is too enticing to visit. Loved the slim lanes, homes, shops, Puppets hanging from the walls...I just can't get enough)
              • Next day, checkout to catch your train :( .

                Say your good byes to the most amazing back packing trip you ever had.

                Total Pageviews