Python advanced Programming Selection good name: Finish

Source: Internet
Author: User

Because of the time relationship, Python advanced programming is not on this side to learn, if the need for friends can see the following network disk for download

# #-*-Coding:utf-8-*-

# # python:2.x

# __author__ = ' Administrator '

#使用API

#跟踪冗长

#创建代码库时, the most common error is the API verbose (API verbosity), when a feature calls to a package that is a group instead of one, the following error occurs

#script_engine包例子

#from script_engine Import Make_context,compile,execute

#a = Make_context ({' A ': 1, ' B ': 3})

# b=compile (' A+b ')

#print Execute (b)

#这个使用场景应该在一个馋嘴的新函数之后提供, as follows

#from Script_engine Import Run as S

#print s (' a+b ', context={' a ': 1, ' B ': 3})

#之后, low-level and advanced functions are available for high-level calls and other low-level function combinations

#构建命名空间树

#要组织一个应该程序API, a simple technique is to build a namespace tree using scenarios and understand how the code is organized

#例如, a named Acme application to provide an engine that knows how to create a PDF file, it will be based on a series of template files and a query on a MySQL database

#acme应用3个部分

"""

A PDF generator

A SQL engine

A collection of templates

As a result, the first draft of the namespace tree may be

Acme

pdfgen.py

Class Pdfgen

sqlengine.py

Class SQLEngine

templates.py

Class Template

"""

#现在, try this namespace in a code saver, and learn how PDFs are created from this application, we'll guess how classes and functions are named and called in an adhesive program similar to the Acme feature, as follows

# from Acme.template import Template

# from Acme.sqlengine import SQLEngine

# from Acme.pdfgen import Pdfgen

# sql_url= ' sqlite:///:memory: '

# def Get_def (q,t):

# Data=sqlengine (Sql_url). Execute (q)

# t1=template (t)

# return Pdfgen (). Create (DATA,T1)

#其他内容不在这里学习了, the required friends can download [Python advanced programming] from above the internet.

#或者从网盘里面下载, the address of the network disk is as follows: http://pan.baidu.com/s/1gdxgz5p

Python advanced Programming Selection good name: Finish

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.