第一范文网 - 专业文章范例文档资料分享平台

PythonWindowsTutorial

来源:用户分享 时间:2025/5/29 4:19:24 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

Using Python To Harness Windows

5.3 A Minimal COM Server

# SimpleCOMServer.py - almost as small as they come! class PythonUtilities: _public_methods_ = [ 'SplitString' ] _reg_progid_ = \ # NEVER copy the following ID # Use \ _reg_clsid_ = \ def SplitString(self, val, item=None): import string if item != None: item = str(item) return string.split(str(val), item) # Add code so that when this script is run by Python.exe, it self-registers. if __name__=='__main__': print \ import win32com.server.register win32com.server.register.UseCommandLine(PythonUtilities)

5.4 Using the minimal server from VB or VBA

Page 17 of 71

6795.doc

Using Python To Harness Windows

5.5 Why write Python COM Servers?

? ?

Easiest way to expose Python functionality to your own or other applications Python is best at the business logic, other tools are best at other things (e.g. VB GUIs)

5.6 Doubletalk – Sample Application

Python Financial Modelling Toolkit. Models “Sets of Books” and “Transactions”

Good candidate for this architecture because ? ?

Very wide general applicability – from local data input app to back-office server

Every company needs to customize it a little!

How could we sell it? ? ? ? ? ? ? ? ? ?

100% Native Windows GUI

Distributed, Dynamic Multi-tier Network Architecture

Embedded Scripting Language – lets you customize the way it works! Extensible Plug-In Architecture Command Prompt for Power Users Integration with Word and Excel Open Database Connectivity

Option to run critical tasks on Unix servers without changing a line of code! Totally Buzzword Compliant!

Page 18 of 71

6795.doc

Using Python To Harness Windows

Now to discuss what the app is about:

5.7 Transactions

Crudely, a movement of money.

All accounts must sum to zero!

Simple two-line (“Double-Entry”) Date: 01/01/1998 Comment: Start the company Cash +10 000 Share Capital -10 000

Multi-line Date: 10/03/1999 Comment: Sell Widgets Cash +117.50 Sales Category 1 -50.00 Sales Category 2 -30.00 Sales Category 3 -20.00 Sales tax on all three (owed to Customs & Excise) -17.50

Functionality: ? Store ? Edit ? Add ? Validate

? effectOn(self, account) ? Extra keys/values

? add, multiply – an algebra for financial transactions!

Page 19 of 71

6795.doc

Using Python To Harness Windows

5.8 Accounts

Accounts form a tree – this is the “Balance Sheet”…

? ?

Represent tree as dotted string notation: “MyCo.Assets.Cash.PiggyBank” Assets, Cash and Expenditure are positive; Liabilities, Income and Profit are negative.

5.9 BookSets

A wrapper around a list of transactions. ? ?

Fundamental change operations ? ?

Querying ? ? ? ?

get history of an account get the ?tree of accounts?

get all balances on date -> Balance Sheet report

get all changes between two dates -> Profit & Loss reports Add/Edit/Delete transactions Rename Account

Load/Save with cPickle (one of Python?s killer features!) Import/Export ASCII text, list/dictionary/tuple structures etc.

Page 20 of 71

6795.doc

搜索更多关于: PythonWindowsTutorial 的文档
PythonWindowsTutorial.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c8kzf631ezc5v45r563hb_5.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top