summaryrefslogtreecommitdiff
path: root/pyasn1/compat/binary.py
blob: f8b63aae88ef89b98e314e3d4f8e3edb3bace436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2016, Ilya Etingof <ilya@glas.net>
# License: http://pyasn1.sf.net/license.html
#
from sys import version_info

if version_info[0:2] < (2, 6):
    def bin(x):
        if x <= 1:
            return '0b' + str(x)
        else:
            return bin(x >> 1) + str(x & 1)
else:
    bin = bin