Differences between revisions 6 and 9 (spanning 3 versions)
Revision 6 as of 2008-11-10 06:48:30
Size: 5341
Editor: ZoomQuiet
Comment:
Revision 9 as of 2009-12-25 07:17:26
Size: 5276
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
[[TableOfContents]] <<TableOfContents>>
Line 6: Line 6:
[[Include(ZPyUGnav)]] <<Include(ZPyUGnav)>>
Line 17: Line 17:
  * subject [CPyUG:61885] [https://groups.google.com/group/python-cn/browse_thread/thread/5658c99025660056 10 個所有人都會想問的關於 Python 語言的問題]   * subject [CPyUG:61885] [[https://groups.google.com/group/python-cn/browse_thread/thread/5658c99025660056|10 個所有人都會想問的關於 Python 語言的問題]]
Line 25: Line 25:
  * [http://wiki.python.org/moin/Why_is_Python_a_dynamic_language_and_also_a_strongly_typed_language Why is Python a dynamic language and also a strongly typed language]?
  * [wiki:/WhyPyDynamicAndStronglyTyped 中文回答]
  * [[http://wiki.python.org/moin/Why_is_Python_a_dynamic_language_and_also_a_strongly_typed_language|Why is Python a dynamic language and also a strongly typed language]]?
  * [[/WhyPyDynamicAndStronglyTyped|中文回答]]
Line 28: Line 28:
  * [http://wiki.python.org/moin/Which_IDE_is_good_for_Python Which IDE is good for Python]?
  * [wiki:/WhichBestIdeForPython 中文回答]
  * [[http://wiki.python.org/moin/Which_IDE_is_good_for_Python|Which IDE is good for Python]]?
  * [[/WhichBestIdeForPython|中文回答]]
Line 31: Line 31:
  * [http://wiki.python.org/moin/Any_good_Python_book%3F Any_good_Python_book Any good Python book?]
  * [wiki:/WhereGoodPythonBook 中文回答]
  * [[http://wiki.python.org/moin/Any_good_Python_book%3F|Any_good_Python_book Any good Python book?]]
  * [[/WhereGoodPythonBook|中文回答]]
Line 34: Line 34:
  * [http://wiki.python.org/moin/Can_I_get_a_job_with_python%3F Can I get a job with python?]
  * [wiki:/CanGetPythonJob 中文回答]
  * [[http://wiki.python.org/moin/Can_I_get_a_job_with_python%3F|Can I get a job with python?]]
  * [[/CanGetPythonJob|中文回答]]
Line 37: Line 37:
  * [http://wiki.python.org/moin/Why_separate_sections_by_indentation_instead_of_by_brackets_or_%27end%27 Why separate sections by indentation instead of by brackets or 'end']
  * [wiki:/WhySectionsByIndentation 中文回答]
  * [[http://wiki.python.org/moin/Why_separate_sections_by_indentation_instead_of_by_brackets_or_%27end%27|Why separate sections by indentation instead of by brackets or 'end']]
  * [[/WhySectionsByIndentation|中文回答]]
Line 40: Line 40:
  * [http://wiki.python.org/moin/Which_GUI_is_best_for_python%3F Which GUI is best for python?]
  * [wiki:/WhichBestGuiForpython 中文回答]
  * [[http://wiki.python.org/moin/Which_GUI_is_best_for_python%3F|Which GUI is best for python?]]
  * [[/WhichBestGuiForpython|中文回答]]
Line 43: Line 43:
  * [http://wiki.python.org/moin/Why_is_Python_slower_than_the_xxx_language Why is Python slower than the xxx language]?
  * [wiki:/WhyPythonSlowerThanxxxLanguage 中文回答]
  * [[http://wiki.python.org/moin/Why_is_Python_slower_than_the_xxx_language|Why is Python slower than the xxx language]]?
  * [[/WhyPythonSlowerThanxxxLanguage|中文回答]]
Line 46: Line 46:
  * [http://wiki.python.org/moin/How_to_start_learning_Python%3F_Any_suggestions How to start learning Python? Any suggestions]?
  * [wiki:/HowtoStartLearningPython 中文回答]
  * [[http://wiki.python.org/moin/How_to_start_learning_Python%3F_Any_suggestions|How to start learning Python? Any suggestions]]?
  * [[/HowtoStartLearningPython|中文回答]]
Line 49: Line 49:
  * [http://wiki.python.org/moin/Is_there_any_tiny_project_or_source_for_participation_or_reference Is there any tiny project or source for participation or reference]?
  * [wiki:/WhereTinyProjectSourceForParticipationReference 中文回答]
  * [[http://wiki.python.org/moin/Is_there_any_tiny_project_or_source_for_participation_or_reference|Is there any tiny project or source for participation or reference]]?
  * [[/WhereTinyProjectSourceForParticipationReference|中文回答]]
Line 52: Line 52:
  * [http://wiki.python.org/moin/How_to_make_exe_on_Windows How to make exe on Windows]
  * [wiki:/HowtoMakeExeOnWindows 中文回答]
  * [[http://wiki.python.org/moin/How_to_make_exe_on_Windows|How to make exe on Windows]]
  * [[/HowtoMakeExeOnWindows|中文回答]]
Line 80: Line 80:
{{{
Line 83: Line 84:
}}}
关于强类型的问题,容易犯的错误:
1. ==判断:比如id之类字段,从HTTP的POST数据里来的,通常都是str类型,但数据库中取出的时候就是int,直接去做==判断就会得出False。
Line 84: Line 88:
关于强类型的问题,容易犯的错误:
1. ==判断:比如id之类字段,从HTTP的POST数据里来的,通常都是str类型,但数据库中取出的时候就是int,直接去做==判断就会得出
False。
Line 95: Line 97:
创建 by -- ZoomQuiet [[[DateTime(2008-08-12T02:57:01Z)]]]
||<^>[[PageComment2]]||<^>[:/PageCommentData:PageCommentData]''||
创建 by -- ZoomQuiet [<<DateTime(2008-08-12T02:57:01Z)>>]

Python最常见10问

gasolin <[email protected]>
reply-to        [email protected]
to      python-cn`CPyUG`华蟒用户组 <[email protected]>
date    Sat, Aug 9, 2008 at 20:44

十问

  1. 為什麼 Python 既是動態語言又是強型別的語言?
  2. 用哪個 IDE 寫 Python 比較好?
  3. 有什麼關於 Python 語言的好書?
  4. 學 python 語言能找到工作嗎?
  5. 為什麼用縮排而不是用括弧或「End」來分段?
  6. 用哪種 GUI 好?
  7. 為什麼 Python 比 xxx 語言慢?
  8. 如何開始學習 Python 語言?有什麼好建議嗎?
  9. 有什麼小巧的 Python source 或專案項目可以參考練手?
  10. 怎麼在 Windows 上直接跑 Python 程式 (不先安裝 Python)?

增补

from    Gary Shi <[email protected]>
reply-to        [email protected]
to      python-cn`CPyUG`华蟒用户组 <[email protected]>
date    Mon, Nov 10, 2008 at 14:38
subject [CPyUG:70834] 关于10个Python语言问题的补充

1. 为什么Python的赋值操作“=”不是表达式? 比如,可以写a=10,可以写a=b=10,但不能写a=(b=10),更不能写while buf = sock.recv(4096): ... 不可否认后种写法在有些时候确实方便,可以少写不少while True: ...

2. 为什么没有do-while循环? 曾经的PEP-315,被defer了,因为老大说不喜欢……

3. 为什么try block的except和final不能一起写? 貌似在py3000中解决了,但要实用还是好遥远……

4. 为什么time.sleep()会抛OSError? 从道理上说,sleep()会返回-1所以应该对应OSError,但实际写的时候基本上新手都会中招,自己写的daemon跑着跑着一个sleep就 被直接throw到整个进程退出。我是觉得,差不多有10%的POSIX调用,返回值是不用检查的,写C的时候有这样的习惯,但在Python里如果忘 记了try..except,后果就会很严重。是不是os模块应该有一个不是那么strict的抛exception的选项?

关于缩排和括号的对比,我个人对缩排倒没有太大的意见,但在几个事情上觉得确实不方便:

1. 邮件标准一般对于行首的空格是自动干掉的,所以在邮件里贴python源代码就变得特别麻烦。
2. 无法自动re-indent,好像很少有程序可以判断原先的indent关系然后重排。
3. 调试的时候,要暂时关掉一段程序比较麻烦,只能写if False:然后把下面的部分indent进去。

关于强类型的问题,容易犯的错误: 1. ==判断:比如id之类字段,从HTTP的POST数据里来的,通常都是str类型,但数据库中取出的时候就是int,直接去做==判断就会得出False。

2. os.exec/os.spawn系调用,一定要求所有参数都是str类型的,有些比如int类型忘记转换就写进去,执行的时候就抛 OSError。


反馈

创建 by -- ZoomQuiet [2008-08-12 02:57:01]

PyTop10FAQ (last edited 2009-12-25 07:17:26 by localhost)