在学MIT公开课。用python讲课。基础不够好。所以在open course 里在看另外一门课程,是stanford的,同时也是python讲课。但属于更入门的课程,更适合完全无基础的同学。

一边学习,一边记录下来。方便以后查阅。这是week2 里面的部分课程,有些跟MIT课程里面重复关于python的不在记录。

Rules for executing an assignment statement
1 Evaluate the expression.This produces a memory address.
2 Store the memory address in the variable.
会分配一块内存;变量里存放的是所指向内存的地址

Rules for legal Python names
1 Names must start with a letter or_.
2 Names must contain only letters,digits,and_.

只能以字母和_开头。只包含字母。数据和_;

Python naming convetion
Use pothole_case in most situations so that other Python programmers have an easier time reading your code
In Python,most variable names use only lowercase letters with underscores to separate word,we call this UNKNOWN case.

命名要有自述性的意义,使其他人更容易理解和阅读。并且大部分用小写字母和下划线来分开表达的变量,我们称之为未知实例。

Python 的命名可以结合大小写。并会分区大小写的
max(a,b,c,d) 会返回其中最大的那个数
abs(....) 会返回正整数

dir(__builtins__) 会返回所有函数接口
help() 会显示该函数的帮助文档

如下面的例子:
help(pow)
pow(...)
pow(x, y[, z]) -> number

With two arguments, equivalent to x**y. With three arguments,
equivalent to (x**y) % z, but may be more efficient (e.g. for longs).

def:a keyword indicating a function definition
def f(x)
return x**2

 

在shell菜单下 restart shell 将会清零之前定义的函数


可以再shell新建windows 然后再里面def 定义自己的类
定义完成后保存,以.py 结尾文件名 。之后在window 的run菜单下run module。

这样便可以在shell里面直接引用定义的变量。

posted on 2012-11-16 10:36  xxppxiaowei  阅读(573)  评论(0编辑  收藏  举报