随笔分类 -  Python

摘要:SWIG是简单包装和接口生成器的缩写,它是一个能用于用于集中语言的工具。一方面,可以通过它使用C语言或者C++编写扩展代码;另一方面,它会自动包装那些代码,以便能在一些高级语言中使用,例如Tcl Python Perl Ruby java. 这就意味着如果决定将系统的一部分使用C语言扩展编写,而不是直接在Python中实现的话,那么C语言扩展库也能在其他语言中使用。当然需要一些不同语言编写的子系统协同工作时,这一点就非常有用。C语言扩展在协同工作时会变得很重要。first step:一个简单的C语言程序:hello.c#include #include int say_hello(void){ 阅读全文
posted @ 2011-08-26 11:25 Rabbit Nick 阅读(841) 评论(0) 推荐(0) 编辑
摘要:2011-8-23Python 里边的parser用法15.5.optparse— Parser for commandline optionshttp://docs.python.org/library/optparse.htmlHere’s an example of usingoptparsein a simple script:from optparse import OptionParser[...]parser = OptionParser()parser.add_option("-f", "--file", dest="filen 阅读全文
posted @ 2011-08-23 22:54 Rabbit Nick 阅读(11277) 评论(0) 推荐(0) 编辑
摘要:时间不够直接跳过前边一些东西,从9.3开始 9.3. A First Look at ClassesClasses introduce a little bit of new syntax, three new object types, and some new semantics. 9.3.1. Class Definition Syntax类语法,下面是一个很简单的class的定义。The simplest form of class definition looks like this:class ClassName: . . . Class defin... 阅读全文
posted @ 2011-08-21 13:37 Rabbit Nick 阅读(356) 评论(0) 推荐(0) 编辑
摘要:6. ModulesIf you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if you want to write a somewhat longer program, you are better off using a text editor to prepare the input for the interpreter and running it with tha.. 阅读全文
posted @ 2011-08-20 16:35 Rabbit Nick 阅读(278) 评论(0) 推荐(0) 编辑
摘要:5. Data Structures¶This chapter describes some things you’ve learned about already in more detail, and adds some new things as well.加了一些新东西而已5.1. More on ListsThe list data type has some more methods. Here are all of the methods of list objects:list.append(x)Add an item to the end of the list; 阅读全文
posted @ 2011-08-20 13:46 Rabbit Nick 阅读(184) 评论(0) 推荐(0) 编辑
摘要:4.7.5. Lambda FormsBy popular demand, a few features commonly found in functional programming languages like Lisp have been added to Python. With thelambdakeyword, small anonymous functions can be created. Here’s a function that returns the sum of its two arguments:lambdaa,b:a+b. Lambda forms can be 阅读全文
posted @ 2011-08-20 12:50 Rabbit Nick 阅读(173) 评论(0) 推荐(0) 编辑
摘要:白看了几天。。其实看得半懂半不懂。。。而且网上有个大牛觉得这本书很不掂。。。还是看官方的教程比较好:网址:http://docs.python.org/tutorial/controlflow.html#more-on-defining-functions 阅读全文
posted @ 2011-08-20 01:58 Rabbit Nick 阅读(132) 评论(0) 推荐(0) 编辑
摘要:第5章对象和面向对象 5.1. 概览 5.2. 使用 from module import 导入模块 5.3. 类的定义 5.3.1. 初始化并开始类编码 5.3.2. 了解何时去使用 self 和 __init__ 5.4. 类的实例化 5.4.1. 垃圾回收 5.5. 探索 UserDict:一个封装类 5.6. 专用类方法 5.6.1. 获得和设置数据项 5.7. 高级专用类方法 5.8. 类属性介绍 5.9. 私有函数 5.10. 小结这一章,和此后的许多章,均讨论了面向对象的 Python 程序设计。5.1.概览下面是一个完整的,可运行的 Python 程序。请阅读模块、类和函数的 阅读全文
posted @ 2011-08-20 01:55 Rabbit Nick 阅读(223) 评论(0) 推荐(0) 编辑
摘要:来自:http://www.kuqin.com/docs/diveintopythonzh-cn-5.4b/html/power_of_introspection/index.html第四章 自省的威力 本章论述了Python众多强大功能之一:自省。正如你所知道的,Python中万物皆对象,自省是指代码可以查看内存中以对象形式存在的其它模块和函数,获取它们的信息,并对它们进行操作。用这种方法,你可以定义没有名称的函数,不按函数声明的参数顺序调用函数,甚至引用事先并不知道名称的函数。4.1.概览下面是一个完整可运行的Python程序。大概看一下这段程序,你应该可以理解不少了。用数字标出的行阐述了 阅读全文
posted @ 2011-08-19 01:05 Rabbit Nick 阅读(196) 评论(0) 推荐(0) 编辑
摘要:1.2. 声明函数象大多数其它语言,Python拥有函数。但是不象C++或Java,它没有独立的接口声明和实现声明。一旦需要一个函数,声明它,编码就行了。根据上个例子:dive into python有写道:def buildConnectionString(params):有几件事情需要注意的。首先,关键字 def 为函数声明的开始。不象VB,Python并不区分有返回值的函数与无返回值的函数。它没有子程序。全部都是函数,所有的函数都以 def 开始。其次,函数没有定义返回的数据类型。实际上,甚至不需要指定是否会返回一个值。函数并不关心第一种情况或第二种情况。如果函数执行了一个 return 阅读全文
posted @ 2011-08-18 15:38 Rabbit Nick 阅读(254) 评论(0) 推荐(0) 编辑
摘要:不得不说python有几个网站:GNURADIO上说的网站:http://docs.python.org/tutorial/introduction.html还有自己搜索到:http://diveintopython.org/我自己的硬件环境:CPU:I3 530内存:4GOS:Ubuntu 10.4第一,安装,在命令行下打入python,发现没按照,输入sudo apt-get install python第二,按照完后,打开 Invoking the Interpreter教程上写的:The Python interpreter is usually installed as/usr/lo 阅读全文
posted @ 2011-08-18 15:03 Rabbit Nick 阅读(437) 评论(0) 推荐(1) 编辑

点击右上角即可分享
微信分享提示