⇤ ← Revision 1 as of 2005-05-31 04:29:55
Size: 3669
Comment:
|
Size: 3691
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 56: | Line 56: |
== 问题解答 == |
2005-05-31开篇
关于我: 我是电子工程毕业的,搞过DSP,现在是c++ 的程序员,会调电路,会写算法,会玩烙铁, 会很多东西,但是都不熟练,就是所谓的样样通, 样样松的状态,痛苦过一阵子,仔细想来这也是我的优点,我想我以后能对软硬件, 以及操作系统都能有所了解,能做一下完整的项目的设计。 另外我的理想是,勤劳致富,环游世界! 引子: 被几个编程高手告知,Python这个东西很好,而且公司有一下东西是是在wxPython下做的。 就萌生了学习它的念头,这后面就是那个牛人,也是我的榜样给我的学习语言的建议: I suggest you just learn python first and forget the other 2 for a while. One reason is that python is a totally different language, it can expand your understanding about object-oriented programming and it is strict, clearly defined too. The other reason is that we also use a lot Python in the company so maybe you can have some real use of it some day. I don't need to pay much attention to perl, especially its OO part. It is not well-designed. As you said, Java is very like C++, after you learn C++ well, you can just pick Java up in several days when you need to use it. 为此我要努力学习! 开始: 在学习前,浏览了很多相关的网站,下载了不少的资源,很快的速度看了一遍 《Programming Python 2nd》,有了个感性的认识。发现了自己最大的缺点就是 缺少练习,现在在看《Python 学习笔记》王纯业的,希望再加深一下感性认识同时 照例子动手写一下。我会记录下来我认为有趣的东西,希望大家多交流指正。 焕然一新的感觉: 1:python 好像很牛,解释型面向对象灵活又强制类型的 语言! 2:第一个练习 Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print "I am here" I am here >>> print "^哈哈_^" ^哈哈_^ 3:"一切皆为对象,对象都有名字"--我还没有感觉呢,姑且记住大牛的总结! 4:基本数据类型和c/c++都很象,但注意"1==1.0" 是真值,这个对我很难理解, 我以前用汇编的,总是想1 是int型和1.0是float,编码方式都不一样,做"==" 其实是在做一个求反的异或,总也不可能返回真的,我猜测,Python是把 int 型默认转换成float了,仅仅是猜测,以后验证吧, 5:None是特殊的变量,表示出错,我以前还认为是不是和c中的NULL一样, 其实不一样的,NULL一般都是宏定义为0的,而None是个有意义的。 6:bool型 很多可以为false 如 0,0.0 ,[],{},None 等,感觉不错,世界应该就是 是和非应在该相互平横些。 7:在学习逻辑表达式的时候,出现麻烦,我照着例子做但是报错,请教各位兄弟 >>> def getTure(): ... return 1 File "<stdin>", line 2 return 1 ^ IndentationError: expected an indented block >>> 这是什么原因呀? 8:注意逻辑关系式的屏蔽(就是有时候可能不运行逻辑关系式内的可执行的东西, 这个在c中也很常见)还要注意c中常用的 cond ? true_expr: false_expr 最好不要用(详见effective c++),python有类似的 东西,所以要好好考虑清楚正确的用法,<cond> or <expr_false> and <expr_true> 也要小心。 以上是python的基本类型,下一篇将是 list和string等 邹胖小 2005年5月31日 祝大家快乐安康