开发者

Python : define a list of a specific type of object

I would like to inherit from a list to produce the myList class, that only accepts one specific type of object (say ints). I am sure decorators can do开发者_开发百科 that elegantly.


What about using arrays?

This module defines an object type which can compactly represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. The type is specified at object creation time by using a type code, which is a single character. The following type codes are defined:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜