5

编程名词辨析(5×10’)

 3 years ago
source link: https://greyli.com/analysis-of-programming-terms-5x10/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

编程名词辨析(5×10’)

在和很多同学的交流中,发现有些编程词语被误用了。今天我们来辨析一下。

我简化了大部分解释,如果需要了解更多,请点链接。如果发现有错,请指正。

包(package)和模块(module)

:一个包含__init__.py文件的文件夹就是一个包,这个文件夹里可以放多个Python模块。比如:

my_package
    - __init__.py
    - hello.py

模块:一个Python文件(.py)就是一个模块。

What’s the difference between a Python module and a Python package?

插件(plugin)和扩展(extension)

在Flask里,插件和扩展没有具体的区别,都指代增强Flask功能的Python包,但通常称作扩展。

参数(parameter)和参数(argument)

参数(形参):函数所期望你传入的参数(即name

def say_hello(name):
    print 'hello,' + name

参数(实参):传给函数的实际的参数(即‘kitty’

say_hello('kitty')

What’s the difference between an argument and a parameter?

函数(function)和方法(method)

函数:为了便于进行管理和重用而包装起来的代码块。

def meow():
    print 'meow meow meow'

方法:在类中定义的函数是方法。

class Cat(object):
    def meow(self):
        print 'meow meow meow'

Difference between functions and methods in Python

表达式(expression)和语句(statement)

表达式:能被打印和赋值的是表达式。比如:

[x for x in y]

语句:任何一行(或多行)Python代码就是语句(包括表达式),比如:

print 42
name = 'john'

What is the difference between an expression and a statement in Python?

本条目发布于2017年2月21日。属于计算机与编程分类,被贴了 Python 标签。 ← 用Flask从零实现豆瓣相册 Flask-Dropzone:为你的Flask程序添加文件上传功能 →

撰写评论 取消回复

电子邮件地址不会被公开,必填项已用*标出。

评论

姓名 *

电子邮件 *

站点

在此浏览器中保存我的名字、电邮和网站。

当有人回复我时,发送电子邮件提醒我。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK