我应该用 Python 重写过时的 tawk 例程吗?
在九十年代初,我购买了 tawk (Thompson awk) 编译器并开发了很多程序为我的公司。该编译器可生成快速可靠的代码,并为 Windows 环境提供许多有用的扩展。
到目前为止,它在 W95、W2K 和 XP 上都可以正常工作,但现在我必须迁移到 W7 / 2008 服务器,我怀疑尝试继续使用这个虽然优秀但过时且不再受支持的产品是否明智。
我向您提出的问题是:
- 对于现实世界的业务应用程序(所有这些应用程序都以批处理模式运行 - 无 GUI),您可以推荐什么?
- 有人从 xxx (此处:awk)到 Python 进行了更大的过渡(手动重新编程)吗?
- 我应该使用什么 Python 实现?
我需要快速文件 I/O 和对 100.000 多个字典元素的广泛随机访问,以进行 1.5 Mio 每月交易 - 哪个是最稳定的版本? 2.7.x? 3.1.x?
- 3.1 支持 Windows 自动化吗?我必须通过 COM 驱动 Excel API,并且需要访问 MS-SQL
- 并且:Python 真的是此类任务的选择吗?
谢谢您的光荣回答
Meiki
in the early nineties I bought the tawk (Thompson awk) compiler and developed since than a lot of programs for my companies. The compiler produces fast reliable code and has a lot of useful extensions for the Windows environment.
Until now it worked in the W95, W2K and XP without problems but now that I have to move to W7 / 2008 Server I am in doubt if it is wise to try to continue with this although excellent but outdated and no more supported product.
My questions to you :
- What can you recommend for real-world business applications (all of them run in batch mode - no GUI) ?
- Has someone made a bigger transition (manual reprogramming) from xxx (here: awk) to Python ?
- What Python implementation should I use ?
I need fast file I/O and extensive random access to 100.000+ dictionary elements for 1.5 Mio monthly transactions - Which is the most stable version ? 2.7.x ? 3.1.x ?
- Does 3.1 support Windows Automation ? I have to drive the Excel API through COM and need access to MS-SQL
- And : is Python really the choice for this kind of task ?
Thank you for your honorable answers
Meiki
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于这些类型的任务,Python 是一个不错的选择。您应该使用 Python 2.7.2,并且由于您使用的是 Windows,因此您可能需要使用 Activestate Python 发行版 http: //www.activestate.com/activepython/downloads 这是标准 Python,捆绑了许多其他有用的库和一个名为 PyPm 的易于使用的包管理器。
另外,您应该看看这里的幻灯片演示http://www.dabeaz.com/generators/ 和这里 http://www.dabeaz.com/generators-uk/index.html 因为 Python 生成器是处理与 AWK 相同类型的批处理的强大方法。
至于 Windows 自动化,适用于 Windows 的 Activestate 发行版包含此功能,或者如果您使用的是 Python.org 发行版,则可以单独下载并安装 pywin。我使用 Python 和 COM 从 Word 文档、Excel 电子表格、Outlook 邮箱和 Lotus Notes 数据库等中提取数据。
如果您想坚持 awk 的处理方式,您可以编写一些 Python 辅助函数,这样您的 Python 程序在 awk 看来就不会显得那么陌生。事实上,pyawk.py 可能已经是您所需要的http://pyawk.sourceforge.net/可以在这里下载http://sourceforge.net/projects/pyawk/files/pyawk/pyawk-0.4/ 但是请注意,自上次更新以来,Python 已经发生了很大的变化。
Python is a good choice for these types of tasks. You should use Python 2.7.2 and since you are on Windows, you may want to use the Activestate Python distribution http://www.activestate.com/activepython/downloads which is standard Python bundled with a number of additional useful libraries and an easy to use package manager named PyPm.
Also, you should have a look at the slide presentations here http://www.dabeaz.com/generators/ and here http://www.dabeaz.com/generators-uk/index.html because Python generators are a powerful way to handle the same types of batch processing that AWK is used for.
As for Windows automation, the Activestate distro for Windows includes this, or you can download and install pywin separately if you are using the Python.org distro. I've used Python and COM to extract data from Word documents, Excel spreadsheets, Outlook mailboxes and Lotus Notes databases among other things.
If you want to stick with the awk style of doing things, you can write some Python helper functions so that your Python programs don't look so foreign to awk eyes. In fact, pyawk.py may already be all that you need http://pyawk.sourceforge.net/ You can download it here http://sourceforge.net/projects/pyawk/files/pyawk/pyawk-0.4/ however be warned that Python has evolved a lot since it was last updated.
毫无疑问,这是将 Tawk 添加到 Django/python 的最佳方式。它解决了我所有的需求。
https://github.com/CleitonDeLima/django-tawkto
Without question this is the best way to add Tawk to Django/python. It solved all my needs.
https://github.com/CleitonDeLima/django-tawkto