Skip to content

Instantly share code, notes, and snippets.

View caglartoklu's full-sized avatar

Çağlar Toklu caglartoklu

View GitHub Profile
@caglartoklu
caglartoklu / module_path.py
Last active December 12, 2015 06:29
Displays the current module name and its path. #python #path
# http://docs.python.org/reference/datamodel.html?highlight=__file__
# Current module name
print __file__
# module1.py
# Path of the current module
import os
print os.path.abspath(os.path.dirname(__file__))
# /home/myusername/projects/project1
@caglartoklu
caglartoklu / is_ironpython.py
Created February 7, 2013 09:49
If the platform is IronPython, this function returns True, False otherwise. #python #ironpython
import sys
def is_ironpython():
"""
If the platform is IronPython, this function returns True, False otherwise.
"""
result = False
if sys.platform == "cli":
result = True
return result
@caglartoklu
caglartoklu / shell_version.sh
Created February 7, 2013 09:48
shell version #shell
`echo $SHELL` --version
@caglartoklu
caglartoklu / encoding.py
Last active December 12, 2015 06:29
Python source encoding.Add the code to the top of your source file. #python #encoding
# -*- coding: utf8 -*-
# http://www.python.org/dev/peps/pep-0263/
@caglartoklu
caglartoklu / where_is_site_packages.sh
Last active December 12, 2015 06:29
Displays the location of the directory "site-packages" of Python.Run it from shell(bash or cmd.exe), not from the Python interpreter itself. #python #shell #path
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
@caglartoklu
caglartoklu / rhel_version.sh
Created February 7, 2013 09:40
Find out Red Hat Linux version #redhat #linux #shell
uname -a
cat /etc/redhat-release