Monthly Archives: April 2012

Showing Exception in detail in python

import sys, os
    raise NotImplementedError("No error")
except Exception, e:
    exc_type, exc_obj, exc_tb = sys.exc_info()
    fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]      
    print(exc_type, fname, exc_tb.tb_lineno)

Regex Expression: |

Syntax: pattern1|pattern2

Search for both of them, if either is found it is true.


 re.findall("(the|top|coder)", "Marius is one of the topcoders.")
['the', 'top', 'coder']

Regex Expression: ^

Syntax: ^pattern

This would return True only if pattern is at the starting of the given text.


re.findall("^http", "")

Regex Expression: $

Syntax: pattern$

Returns True if pattern is in the end of given text


 re.findall("in$", "")

Regular Expression: .

Syntax: pattern.

Use to match a single character.

 >>> re.findall("htt.", "")

>>> re.findall("ht..", "")

Regular Expression: { }

Syntax: Pattern{number of times pattern must repeat continuously}

It multiplies the pattern number of times given within the braces and then search for it in the given text. In the following example it multiplies ‘t’ twice thus pattern to be searched is ‘tt’


>>>re.findall("t{2}", "")

Regular Expression: { ,}

Syntax: Pattern{n,}

Matches n or more occurrences of preceding expression.


>>> re.findall("t{2}", ""

Basics of Regular Expressions in Python

The Future of Gaming Technology

We have the responsibility to develop something similar for generations to come -:)