python中怎么赋值符号_如何在Python中模拟赋值运算符重载?

小编典典

我最终创建了一个名为ModelMeta的Model元类,该元类注册了类型化的属性。

在这种情况下,类型化的属性是图形数据库“属性”,它们都是Property类的所有子类。

这是一个示例模型声明:

# people.py

from bulbs.model import Node, Relationship

from bulbs.property import String, Integer, DateTime

from bulbs.utils import current_datetime

class Person(Node):

element_type = "person"

name = String(nullable=False)

age = Integer()

class Knows(Relationship):

label = "knows"

created = DateTime(default=current_datetime, nullable=False)

用法示例:

>>> from people import Person

>>> from bulbs.neo4jserver import Graph

>>> g = Graph()

# Add a "people" proxy to the Graph object for the Person model:

>>> g.add_proxy("people", Person)

# Use it to create a Person node, which also saves it in the database:

>>> james = g.people.create(name="James")

>>> james.eid

3

>>> james.name

'James'

# Get the node (again) from the database by its element ID:

>>> james = g.people.get(james.eid)

# Update the node and save it in the database:

>>> james.age = 34

>>> james.save()

# Lookup people using the Person model's primary index:

>>> nodes = g.people.index.lookup(name="James")

看到…

灯泡模型API:http://bulbflow.com/docs/api/bulbs/model/

灯泡模型快速入门:http://bulbflow.com/quickstart/#models

2021-01-20

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值