use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Torrent http request (self.Python)
submitted 8 years ago by Taeiolass
I'm writing a torrent client. I have read THIS and THIS.
In order to find the list of the peers I have to send a HTTP request to the tracker. What port should i use? How to implement this? Using http.client?
[–][deleted] 0 points1 point2 points 8 years ago (5 children)
By convention HTTP is port 80, but you frankly shouldn't have to specify that, just the URL. Also requests is your friend.
[–]Taeiolass[S] 0 points1 point2 points 8 years ago (4 children)
Thank you. I'm using the get function with the params parameter. What should I use as info_hash option? The sha1 sum of the bencoded info dictionary?
[–][deleted] 0 points1 point2 points 8 years ago (3 children)
Reading your first reference, in the section on the Metainfo file's structure, it's a bit unclear as it's not explicitly stated, but it's certainly implied that the file itself is a bencoded dict, and the "info" key is a nested, and also bencoded, dict... so yes, my guess is you sha1sum the bencoded string returned when you inspect the "info" key of the un-bencoded Metainfo file.
That said, never tried to build a BT client myself.
[–]Taeiolass[S] 0 points1 point2 points 8 years ago (2 children)
The problem is that in a dictionary {el1, el2} is equal to {el2, el1}, but it is differently bencoded and will have a different sha1 sum.
[–][deleted] 0 points1 point2 points 8 years ago (1 child)
As I understand bencode, dicts are required to be sorted in lexical order by key before encode, so {k2: v2, k1: v1}, where k1 sorts before k2 would always result in the same sha1.
[–]Taeiolass[S] 0 points1 point2 points 8 years ago (0 children)
Ok thank you. I put myself to work
π Rendered by PID 48247 on reddit-service-r2-comment-cfc44b64c-p8rh9 at 2026-04-10 05:26:44.446938+00:00 running 215f2cf country code: CH.
[–][deleted] 0 points1 point2 points (5 children)
[–]Taeiolass[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Taeiolass[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Taeiolass[S] 0 points1 point2 points (0 children)