全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 python论坛
1071 1
2015-05-01
Everything is an object in Python, even simple numbers. Python programs can be decomposed into modules,
statements, expressions, and objects, as follows:

1. Programs are composed of modules
2. Modules contain statements
3. Statements contain expressions
4. Expressions create and process objects

Here are built-in object types:
1. Basic Core types: Numbers, Strings, Lists, Dictionaries, Tuples, Files, Sets, Booleans, types, None
2.  Program unit types: Functions, modules, classes
3. Implementation related types: Compiled code, stack tracebacks

all built-in types come in with free operations attached to them.  Pythong is dynamically types -- your operations depend on
what you assignment to the object. It is also strongly typed, you can perform only operations that are valid.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2015-5-1 23:11:31
some notes:
1. strings are immutable. for ex. you have to assign it to a list, change the list, and join back to a string. or use bytearray()
2. tuples are immutable. they are not used as often as lists in practice, but their immutability is the whole point when used.
3. use dir() and help() to find how to use an object/type
4. lists are positionally ordered collections of arbitrarily types objects, not necessarily homogeneuous, and they have no fixed size. they are mutable.
5. core data types support arbitrary nesting -- we can nest them in any combination, and as deeply as you like.
6. list comprehension expression is very powerful way to process sequence structures, example:
d=[c*2 for c in 'world']
related tools are map and filter.
7. Dictionaries are mappings from keys to values. use d={} to init dictionaries.
8. missing keys test: if not 'f' in d.
9. sorting keys in map: for key in sorted(d)
10. File objects are the main interface to external files on computer.
11. Binary Bytes files and Unicode text files.
12. sets are created like X=set('hello') or Y={'a',b','c'}. they are unordered collection of unique and immutable objects. it supports set operations as in set theory.
13. user defined classes
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群