Python Project Structure
Python was conceived as a scripting language. Unlike compiled languages like C or Java, Python files are designed to be directly runnable.
* RunMe.java -p someargument < Not ok!
* RunMe.py -p someargument < Ok!
This is convenient for small scripts, but doesn’t help applications. Since you are intended to run .py files directly, Python projects should not have source (src) or binary (bin) folders. Having a source folder makes a program difficult to run. The root of the Python package structure should be the root of the project.
For the same reason, the test folder should not be separate. It should be a package in the main project. Since the root folder is the root package, you won’t have much choice.
Example
引用
* MyProject
o __init__.py
o model
+ __init__.py
+ user.py
o service
+ __init__.py
+ user_service.py
+ ldap_user_service.py
o test
+ __init__.py
+ unit
# __init__.py
# service
* __init__.py
* user_service_test.py
+ functional
# __init__.py
# service
* __init__.py
* user_service_test.py
If you’re new to Python, please note that those __init__.pys are required. They tell Python which folders contain Python files. This is Python’s way of allowing you to have other folders, such as config, that don’t contain source files.
Note
You should specify exactly one class per file. It makes your code easier to find and read.
参考链接:http://www.connorgarvey.com/blog/?p=184
如何将unicode编码的含有中文字符的url地址转换成符合url地址要求的地址?
pageUrlAscii = pageUrl.encode('utf-8')
pageUrlValid = urllib.quote(pageUrlAscii, safe=':/')
pageSource = urllib2.urlopen(pageUrlValid, None, 5).read()
参考链接:http://stackoverflow.com/questions/120951/how-can-i-normalize-a-url-in-python
分享到:
相关推荐
python笔记python笔记python笔记python笔记python笔记python笔记python笔记python笔记python笔记
Python笔记 ,python笔记全,Python源码
python笔记
中文 Python 笔记
Python笔记PythonPython笔记笔Python笔Python笔记记记Python笔记
Python 笔记源码综合下载.zip
Python笔记完整版.md
Python 笔记源码——内含python后端&机器学习等.zip Python 笔记源码——内含python后端&机器学习等.zip Python 笔记源码——内含python后端&机器学习等.zip Python 笔记源码——内含python后端&机器学习等.zip ...
python笔记,python课程笔记 python基础 flask框架
python笔记.md
Python基础语法,到包的使用 Python高级语法,常用模块 WEB前端 数据库 Django框架 爬虫及其框架
python笔记大全 高清pdf版 适合有一定语言基础,想快速对python有全面了解的人士阅读
到http://www.python.org/下载最新的稳定版本Python。在Windows 平台下, 安装过程和普通的软件没有什么区别,一路下一步就可以了。
python自学ing,自己总结了一些python的知识点,python笔记1。
python笔记整理
自己总结的python最最基础的笔记
python笔记
python笔记
python笔记