Git Product home page Git Product logo

cs-notes's Introduction

Hi,I'm Future Deng! 👋

Python全栈开发工程师

logo

  • 🔭 现在就职于 赛力斯重庆新能源设计院有限公司
  • 👋 岗位职责
    • 主导自动化测试平台研发
    • 主导设计自动化测试平台软件架构
    • 主导整车功能测试自动化测试方案开发
    • 主导ADS智能辅助驾驶自动化测试方案开发
  • 🌱 工作中常用技术栈
    • Python、Golang、c++
    • React、Vue、Angular
  • ⚡ 研究方向:
    • Python Web 服务器开发
    • Python 自动化测试开发
    • Python 大数据分析开发
    • Python NLP自然语言处理算法开发
    • Python 图像识别、检查算法开发

Follow Me

个人博客 Github

Show Code

from abc import ABC, abstractmethod

class Validator(ABC):
    """
    使用python描述器来验证名字是不是“future.deng”
    """

    def __set_name__(self, owner, name):
        self.private_name = '_' + name

    def __get__(self, obj, objtype=None):
        return getattr(obj, self.private_name)

    def __set__(self, obj, value):
        self.validate(value)
        setattr(obj, self.private_name, value)

    @abstractmethod
    def validate(self, value):
        pass


class ValidatorName(Validator):
    """
    使用类继承的方式实现validate方法
    """
    def __init__(self, is_validator_name=True):
        self.is_validator_name = is_validator_name

    def validate(self, value):
        if self.is_validator_name:
            if value != 'Future Deng':
                raise ValueError("Future Deng 的私人代码,必须传入'Future Deng' 才能被实例化")


class PythonWebEngineer:

    name = ValidatorName(is_validator_name=True)

    def __init__(self, name):
        self.name = name
        self.age = 28
        self.role = "Python Engineer"
        self.language_spoken = ["zh_CN", "en_US"]
        self.skill = ["Python", "React", "Golang"]


if __name__ == '__main__':
    me = PythonWebEngineer('Future Deng')
    me.name
    
# 输出结果
# Future Deng

#   me = PythonWebEngineer('Future Dengsss')
#   me.name

# 若是传入错误的值 'Future Dengsss'
"""
  File "/Users/futuredeng/opt/backendxh/dsz.py", line 161, in validate
    raise ValueError("Future Deng 的私人代码,必须传入'Future Deng' 才能被实例化")
ValueError: Future Deng 的私人代码,必须传入'Future Deng' 才能被实例化
"""

cs-notes's People

Contributors

0xkookoo avatar crossoverjie avatar cyc2018 avatar fanofxiaofeng avatar hustcoderhu avatar imhuster avatar jiahaochang avatar kwongtailau avatar linehk avatar linkcoder avatar linkwk7 avatar linw7 avatar luocaodan avatar machinechen avatar moqimoqidea avatar nopainanymore avatar onefansofworld avatar peiel avatar pualrdwade avatar qizhengzhong11 avatar seventheluck avatar silverados avatar somone23412 avatar xbhoneybee avatar xiangflight avatar xiangmingzhe0928 avatar xunzhuo avatar yif-hong avatar zhangxuelong10 avatar ziyitony avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.