V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2013-01-16 18:07:15 +08:00 · 4142 次点击
    这是一个创建于 4109 天前的主题,其中的信息可能已经有所发展或是发生改变。
    3 条回复    1970-01-01 08:00:00 +08:00
    thedevil7
        1
    thedevil7  
       2013-01-17 13:41:07 +08:00
    昨晚手机看了代码, 今天用电脑来回复.

    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
       2013-01-18 01:01:44 +08:00 via Android   ❤️ 1
    @thedevil7

    非常感谢! ! ! 改进版本, 稍后奉上.
    imcj
        3
    imcj  
       2013-01-18 09:57:09 +08:00
    @manoon 楼上的楼上真能打字,你用pylint跑一下吧。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5292 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 07:39 · PVG 15:39 · LAX 00:39 · JFK 03:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.