15.1 User-defined typesWe have used many of Python’s built-in types; now we are going to define a new type. As an example, we will create a type called Point that represents a point in two-dimensional space.In mathematical notation, points are often…
17.1 Object-oriented featuresPython is an object-oriented programming language, which means that it provides features that support object-oriented programming.It is not easy to define object-oriented programming, but we have already seen some of its…
16.1 TimeAs another example of a user-defined type, we’ll define a class called Time that records the time of day. The class definition looks like this: class Time(object): """Represents the time of day. attributes: hour, minute, second &qu…
十五. Python基础(15)--内置函数-1 1 ● eval(), exec(), compile() 执行字符串数据类型的python代码 检测#import os 'import' in code ① eval : 有返回值, 适用于执行计算语句, 例如eval("4+3"). ② exec : 没有返回值, 适用于执行流程控制语句, 例如exec(a = b if b>c else c) ③ complie: code1 = 'for i in range(0,3):…
The original link: http://zeroturnaround.com/rebellabs/reloading-objects-classes-classloaders/ A Bird's Eye View 鸟瞰 The first thing to understand when talking about reloading Java code is the relation between classes and objects. All Java code is ass…
Before understanding metaclasses, you need to master classes in Python. And Python has a very peculiar idea of what classes are, borrowed from the Smalltalk language. 在理解元类之前,你先要掌握Python的类.Python中的类是借鉴了小众语言的特殊的类. In most languages, classes are just p…
<Web Scraping with Python> Chapter 1 & 2: Your First Web Scraper & Advanced HTML Parsing BeautifulSoup Key: P5: urlib or urlib2? If you’ve used the urllib2 library in Python 2.x, you might have noticed that things have changed somewhat…