节选自:《流畅的 Python》

环境:Python 3.6

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class A: # 默认继承自 object
def ping(self):
print('ping:', self)


class B(A):
def pong(self):
print('pong:', self)


class C(A):
def pong(self):
print('PONG:', self)


class D(B, C):
def ping(self):
super().ping()
print('post-ping: ', self)

def pingpong(self):
self.ping()
super().ping()
self.pong()
super().pong()
C.pong(self)
阅读全文 »

翻译自:Relationship Configuration

基本关系模式

下面每一节需要导入如下模块:

1
2
3
4
5
from sqlalchemy import Table, Column, Integer, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

一对多

1
2
3
4
5
6
7
8
9
class Parent(Base):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)
children = relationship("Child")

class Child(Base):
__tablename__ = 'child'
id = Column(Integer, primary_key=True)
parent_id = Column(Integer, ForeignKey('parent.id'))
阅读全文 »

必备插件

优化编辑器

  • Guides: 高亮缩进基准线
  • indent-rainbow: 优化缩进点
  • Better Comments: 优化注释
  • Terminal: 可以在编辑器底边栏添加一个控制台按钮,便于鼠标快速访问
  • Code Outline: 显示代码大纲
阅读全文 »

前置条件:安装 gitnodejs

初始化

1
2
3
npm install -g hexo
hexo init <folder>
cd <folder>
1
2
npm install
npm install -D hexo-deployer-git
阅读全文 »

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

0%