Head first Python学习笔记整理
Preparethe python distribution:
1, Beginby creating a folder for your module.
2, Createa file called "setup.py" in your new folder.
From distutils.core import setup
Setup(
Name = 'nester' ,
Version = '1.0.0',
Py_modules = ['nester'],
Author = 'hfpython',
Author_email ='hfpython@headfirstlabs.com',
Url = 'http://www.headfirstlabs.com ',
Description = 'A simpleprinter of nested lists',
)
3, Builda distribution file.
$ python3 setup.py sdist
4,Install your distribution into your local copy of Python
$ python3 setup.py install
/nestfer
MANIFEST
/build
/lib
nester.py
/dist
nester-1.0.0.tar.gz
nester.py
nester.pyc
setup.py
Definethe optional argument in function could avoid the update error from previousprogram when the new module adding argument.
Using "try/except" statement lets you concentrate on whatyour code needs to do and it lets you avoid adding unnecessary code and logicto your programs.
ValueError | Occurs when your data does not conform to an expected format |
IOError | Occurs when your data cannot be accessed properly (eg. Perhaps your data file has been moved or renamed.) |
With as , statement to use less code to do the try/except/finallyprocedure to get rid of the worry about close file.
List iterate: clean_mikey = [sanitize(each_t) for each_t in mikey]
Syntax sugar: To extract the data you need, replace all of that list iteration code in your current program with four calls to sorted(set(...)[ 0:3])
Realize functions first, than concatenate them to more simplifiedcodes.
Web development: MVC pattern
Model | Code to store (and sometimes process) your webapp's data |
View | Code to format and display your webapp's user interface(s) |
Controller | Code to glue your webapp together and provide its business logic |
May need Head first HTML to learn some method to edit webpage.
YATE: Yet Another Template Engine
CGI: the Common Gateway Interface, which allows a web server to runa server-side program
CGI script: another name for a server-side program.
HTML-generating helper function.
Write some code to generate HTML for your webapp's UI
MVC pattern and using CGI to launch the webapp
@property
A decorator that lets you arrange for a class method to appear as if it is a class attribute.
Data exchange format: XML or JSON
Debug method:
Output your script sends to standardoutput by default
Import sys
Set the argument file = sys.stderr
Standard library's JSON library can work with Python's built-intypes, but not with objects.
The solution to this problem is straightforward: add a method toclass to convert data into a dictionary.
SL4A - Py4A, Python for the Android development.
Json lab: json.dumps() to create a stringed version of a Pythoncode.
Json.loads() to create a Python type from a JSON string.
Data sent using JSON needs to have its content-type: set toapplication/json.
Sys module provides the sys.stdin, sys.stdout and sys.stderr inputstreams.
SQLite, shown GUI with Firefox's extension.
GAE Python 2.5, NoSQL or GQL.
SQL = Structured Query Language, mainly for database management,like sheets
GQL, row -> entity, column -> property
Book recommendation:
Dive into python 3
Python
Python essential reference
Learning python
Programing in python 3: A complete introduction to the python language
---------------------
3月以来由于工作调整滞后了不少进度,行动力下降比较明显。通过这段时间的学习,结论是要落到一个具体的项目上来提升自己的经验,需要一个有挑战,但是通过一定的努力又能实现的目标来激励反馈。
在具体实施的时候,也想了很多,虽然自己玩很多游戏,但是选择游戏作为目标还是没有什么头绪。在3月的第二周到第三周,由同学的推荐阅读了一些Flask构架的文章(https://exploreflask.com),之后才读到head first python里关于webapp的地方,对构架,web后端也更方便理解。如果只是做个简单的blog,利用树莓派在存在更简单的部署方法(http://blog.eqoe.cn/posts/website-on-raspberry-pi.html)。
每天工作结束之后回来差不多要看4个小时的书,有时候也会精疲力竭地思考我学习编程的动机,思绪也就飘到了与工作内容相关的事情。作为传统工程行业的从业者,在大公司跟小公司也都待过,在标准化流程的执行与公司调整节奏上,明显是小公司更胜一筹,大公司硬件配置的齐全,要什么也有什么,但是实施的时候出力不讨好,很多大龄工程师也都又返回传统纸质办公模式,不愿意付出学习成本。
工业4.0的概念提出,以后对传统行业,尤其是制造业的改造是大势所趋。在今天读完The Global Manufacture Revolution之后,其中提到的PRIDE模式中的E, empowered by the IT technology倒是指明了方向。尤其是全球布局的事务对办公流程以及产品生产状态的整合,设计,加工,销售团队的协作要求甚高。因此脑洞也转移到了SaaS方向,打算以此为方向继续深挖。那么可能就会更倾向于选择web后端为以后的发展方向。