python
文章平均质量分 64
zhangxlubc
这个作者很懒,什么都没留下…
展开
-
python: hasattr()
The hasattr() method returns true if an object has the given named attribute and false if it does not. # hasattr(object,name) class FPGA: dev_type = "arria" dev_pack = "fbga" a...原创 2018-11-14 12:27:41 · 447 阅读 · 0 评论 -
python: understand super()
super() function allows the subclass to call the superclass methods explicitly, useful in inheritance. note: there is some difference between python2 and python3 in use of super(). here is an examp...原创 2018-12-12 15:44:16 · 235 阅读 · 0 评论 -
python: data structure - Queue
if dealing with millions data, an effcient container is needed: queue List: slow for inserting; Set: slow for checking, extension, searching, and soring Queue: FIFO and LIFO FIFO queues (queue) use...原创 2018-11-25 08:33:10 · 191 阅读 · 0 评论 -
python: data structure - dictionaries
dictionaries are extremely efficient at looking up a value, given a specific key object that maps to that value. there is a key and the corresponding value associated with that key for each dictionary...原创 2018-11-20 14:23:46 · 324 阅读 · 0 评论 -
python: data structure-tuples and namedtuples
tuples tuples are objects that can store a specific number of other objects in order, and are immutable. the benefit of tuple's immutability is they can be used as keys in dictionaries, and in other ...原创 2018-11-20 13:31:15 · 143 阅读 · 0 评论 -
python: @property
source: http://python.jobbole.com/80955/ and http://www.blog.pythonlibrary.org/2014/01/20/python-201-properties/ Python has a neat little concept called a property that can do several useful things. ...转载 2018-11-18 03:09:41 · 95 阅读 · 0 评论 -
python: data structure-list
List is a collection which is ordered and changeable. Allows duplicate members. Tuple is a collection which is ordered and unchangeable. Allows duplicate members. Set is a collection which is uno...原创 2018-11-21 13:36:42 · 190 阅读 · 0 评论 -
python: __name__
simply say: the __name__ always points to the name space of the currently running module. so, if it's running in an imported module, then calling __name__ would return the name of that module; if it'...原创 2018-11-19 02:48:17 · 140 阅读 · 0 评论 -
Python 3's f-Strings: An Improved String Formatting Syntax (Guide)
source: https://realpython.com/python-f-strings/ As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less prone to error than other w...转载 2018-11-19 02:36:37 · 356 阅读 · 0 评论 -
python: understand 'self' and '__init__'
reference: https://micropyramid.com/blog/understand-self-and-__init__-method-in-python-class/ https://stackoverflow.com/questions/8609153/why-do-we-use-init-in-python-classes Before understanding...原创 2018-12-10 16:49:35 · 161 阅读 · 0 评论