skip to navigation
skip to content

Not Logged In

bcoding 1.4

bencoding & -decoding library

Latest Version: 1.5

yet another… but mine is fast as hell.

install

pip install bcoding

use

from bcoding import bencode, bdecode

decoding:

# decoding from binary files or streams:
with open('some.torrent', 'rb') as f:
        torrent = bdecode(f)
        print(torrent['announce'])

# decoding from (byte)strings:
one = bdecode(b'i1e')
two = bdecode('3:two')

encoding (note that any iterable or mapping can be bencoded):

# encoding into binary files or streams:
bencode({'a': 0}, sys.stdout.buffer) # ⇒ d1:ai0ee

# encoding to bytestrings:
assert bencode(('a', 0)) == b'l1:ai0ee'
 
File Type Py Version Uploaded on Size
bcoding-1.4.tar.gz (md5) Source 2013-05-21 2KB
  • Downloads (All Versions):
  • 83 downloads in the last day
  • 479 downloads in the last week
  • 1184 downloads in the last month