这是我的第一个问题,如果在代码示例方面有点长,我会道歉.
作为工作申请的一部分,我被要求编写一个暴露了一些字段的Bit Torrent文件解析器.我做了代码,并被告知我的代码"不是我们从团队领导要求的水平".哎哟!
这很好,自从我编码以来已有多年,并且列表理解,生成器在当天不存在(我从COBOL开始,但用C,C++编写等).对我来说,下面的代码非常干净.有时,没有必要使用更复杂的结构,语法或图案- "保持简单".
我可以请一些Python大师来批评这段代码吗?我相信其他人可以看到代码可以改进的地方.还有更多评论等(bencode.py来自http://wiki.theory.org/Decoding_bencoded_data_with_python)
我能想到的领域:
我个人为这段代码感到自豪,所以想知道我需要改进的地方.谢谢.
#!/usr/bin/env python2
"""Bit Torrent Parsing
Parses a Bit Torrent file.
A basic parser for Bit Torrent files. Visit http://wiki.theory.org/BitTorrentSpecification for the BitTorrent specification.
"""
__author__ = "...."
__version__ = "$Revision: 1.0 $"
__date__ = "$Date: 2012/10/26 11:08:46 $"
__copyright__ = "Enjoy & Distribute"
__license__ = "Python"
import bencode
import argparse
from argparse import RawTextHelpFormatter
import binascii
import time
import os
import pprint
torrent_files = …Run Code Online (Sandbox Code Playgroud)