|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/learn-python-data-model/
课程评论:没有评论
课程名称:Python中特殊方法的力量。让你的类更出色! 课程概述:人们常说,Python是一种直观的编程语言,初学者可以快速编写第一段程序,而更高级的程序员能够合理猜测如何使用之前未接触过的Python部分。许多第三方库的工作方式也符合我们的预期。我们大约80%的时间都在使用操作符(如+、-、*、/)进行计算,使用for循环遍历列表,利用len()函数计数,以及通过索引访问列表中的元素。随着时间的推移,开发者渐渐不需要再思考这些语言特性,便能自如地使用它们。 但为什么以及如何会发生这种情况呢?在本课程中,你将学习如何设计类和对象,以支持常见的语言特性,使其他程序员能够智能地推测如何使用它们。你将学习如何支持迭代、下标访问(索引)、上下文管理器、哈希、相等性检查等。 完成本课程后,你将能够: - 解释Python数据模型、魔术方法、双下划线方法和特殊方法名称的来源。 - 编写索引器以支持通过__getitem__方法进行下标访问。 - 运用__iter__和__next__使对象可迭代。 - 定义对象身份。 - 使用__hash__使对象可哈希。 - 指定语言特性,通过特殊方法__eq__、__ne__、__lt__、__gt__、__le__、__ge__实现。 - 使对象可调用,通过__call__方法。 - 描述对象如何通过__new__和__init__方法构造。 - 将现有代码包装成上下文管理器,通过__enter__和__exit__方法。 本课程时长为2小时,每个主题都展示了如何通过实现特殊方法使类变得更加Pythonic,这些特殊方法是对象的秘密武器。本课程没有练习,适合拥有基础Python经验的开发者,或是从其他语言(如C#、Java、JavaScript、C++)转来的开发者,他们希望了解Python独特的语言特性。 本课程由Loek van den Ouweland教授,他是一位拥有25年经验的资深软件工程师,曾创建Windows平台的Wunderlist、Microsoft To-do和Mahjong,并有15年教授软件工程的经验。
People say that python is an intuitive language to learn and use. Beginners write their first programs in no time and more advanced programmers make educated guesses how to use parts of Python they have never used before. Even third-party libraries seem to work exactly how you expected.80% of our time we are using operators like +-/* to calculate, use for-loops to go through lists, use len() to count and indexers to access elements from lists. After a while you don't even have to think about these language features anymore. You just use them and expect things to work the same way everywhere.But why and how does this work? In this course, you learn how to design your classes and objects to support common language features so other programmers can make smart guesses about how to use them. You learn how to support iteration, subscripting (indexing), context managers, hashing, equality checking etc.After this course, you are able to:- Explain the origin of the names Python datamodel, magic methods, dunder methods and special methods.- Write an indexer to support subscripting with the __getitem__ method- Apply __iter__, __next__ to make your objects iterable- Define the object identity- Use __hash__ to make objects hashable- Specify language featureswith special methods __eq__, __ne__, __lt__, __gt__, __le__, __ge__- Make objects callable with __call__- Describe how objects are constructed by methods __new__ and __init__- Wrap existing code into context managers with __enter__ and __exit__The length of this course is 2 hours. Each topic shows clear examples of how to make your classes more Pythonic by implementing special methods, the secret weapon of your objects. This course has no exercises. This course is meant for developer with basic Python experience who want to improve their skills or developers who bring experience from another language like c#, java, javascript, c++ and want to learn about Pythons unique language features.This course is taught by Loek van den Ouweland, a senior software engineer with 25 years of experience. Loek is the creator of Wunderlist for windows, Microsoft To-do and Mahjong for Windows and has 15 years of experience teaching software engineering to a wide variety of students.