Skip to content

Instantly share code, notes, and snippets.

View s16h's full-sized avatar

Shahriar Tajbakhsh s16h

View GitHub Profile
try:
# some code that might raise exception
except:
# code to handle exception
finally:
# code to run regardless of exception
#!/usr/bin/python
def has_balanced_delimiters(string, delimiters={'(': ')', '[': ']', '{': '}'}):
"""
Parses a string to determine if it contains balanced delimiters.
A balanced delimiter string starts with an opening character ((, [, {), ends
with a matching closing character (), ], } respectively). A balanced
delimiter string may contain any number of balanced delimiters.
"""
@s16h
s16h / getPath.c
Created November 8, 2012 23:42
A short C function to get the current value of the PATH environment variable.
/* getenv example: getting path */
#include <stdio.h>
#include <stdlib.h>
int main ()
{
char * pPath;
pPath = getenv("PATH");
if (pPath!=NULL)
printf ("The current path is: %s",pPath);