推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
manoon
V2EX  ›  Python

贴一个“自己写”的小工具。ImgSending

  •  
  •   manoon · Jan 16, 2013 · 5278 views
    This topic created in 5005 days ago, the information mentioned may be changed or developed.
    3 replies  •  1970-01-01 08:00:00 +08:00
    thedevil7
        1
    thedevil7  
       Jan 17, 2013
    昨晚手机看了代码, 今天用电脑来回复.

    1. 不知道你的环境是什么, 不过从代码本身来看, 没有明显的地方指明到底用的是 Python2, 还是 Python3. 从另一个角度讲, 为了方便 unix 用户, 首行加上 #!/usr/bin/env python2/3 后可以直接执行.(由 print 发现, 原来是 Python2 啊)

    2. 代码风格. 参考: PEP8 和 PyQt 库的命名方式.
    -- 2.1 不规则的空行.
    -- 2.2 命名, 特别是函数的命名.
    ---- 个人认为, 如果用 PyQt 的库的话, 和它保持一致使用 mixedCase 比较统一, 而不用 CamelCase.
    -- 2.3 "=" 左右的空格.
    -- 2.4 引入库的顺序, 先 os 再第三方库, 再自己的库.
    ---- import os,sys,ftplib,time 这样的引入一般分为多行.
    -- 2.5 对于 None 的比较, 用 is/is not 而不是 =/!=. line 78.

    3. 既然是 Gui, 弄几个 QLineEdit 和几个 QPushButton 设置一下图片路径和 ftp 地址以及用户名密码应该不麻烦的.

    4. -- textEdit=QTextEdit()
    -- self.textEdit=textEdit

    我觉得如果只是这样, 不需要对 textEdit 进行更多的操作(setText等), 直接 self.textEdit = QTextEdit() 就好了.

    ps. 个人比较喜欢 Python3 的 connect 方式. self.pushButton.connect(self.buttonPushed)
    manoon
        2
    manoon  
    OP
       Jan 18, 2013 via Android   ❤️ 1
    @thedevil7

    非常感谢! ! ! 改进版本, 稍后奉上.
    imcj
        3
    imcj  
       Jan 18, 2013
    @manoon 楼上的楼上真能打字,你用pylint跑一下吧。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2923 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 10:24 · PVG 18:24 · LAX 03:24 · JFK 06:24
    ♥ Do have faith in what you're doing.