Learning Python-Concept of sequence,mapping and polymorphism

来源:互联网 发布:网络推广无限营销 编辑:程序博客网 时间:2024/05/18 15:04

1. Sequence:is a positionally orderedcollection of objects. Strings,lists,and tuples are all sequences in Python.

They share common sequenceoperations ,such as indexing,slicing,concatenation,but also have type-specific method calls

(A related term, “iterable,” means either a physical sequence, or a virtual one that produces its items on request.)


2. Mapping:The term “mapping” denotes an object that maps keys to associated values

Python’s dictionary is the only mapping type in the core type set. 

Mappings do not maintain any left-to-right positional ordering; they support access to data stored by key, plus type-specific method calls.


3.“Polymorphism” :means that themeaning of an operation (like a +) depends on the objects being operated on

This turns out to be a key idea (perhaps the key idea) behind using Python well—not constraining code to specific types makes that code automatically applicable to many types.

0 0