Cerca

Heus ací els resultats de la cerca.

2.4 Decorators
214 Resultats, Darrera modificació:
= 2.4 Decorators A decorator is one of the design patterns that describes the structure of related objects. Python is able to decorate functions, m
2.6 Abstract classes
99 Resultats, Darrera modificació:
lities or an order in a class hierarchy. When you develop a system in a group of programmers, it would... her classes, a kind of contract between a __class designer__ and a __programmer__: * the class designer sets requirements regarding methods that must be implemented by just declaring them, but not defining them in detail. Suc
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
66 Resultats, Darrera modificació:
ses: superclasses (parents) and their subclasses (descendants). Inheritance creates a class hierarchy.... inherits all the traits (methods and attributes) defined inside any of the superclasses. This means ... class, not from scratch, but by using an already defined repertoire of traits. The new class inherits... to using multiple inheritance in Python. You can derive any new class from more than one previously d
2.7 Encapsulation
60 Resultats, Darrera modificació:
t inheritance, polymorphism, and abstraction). It describes the idea of bundling attributes and method... mple: When your money ( **attribute value** ) is deposited in the bank account ( **object** ), you **... ount balance. But you can always make use of some dedicated interfaces (methods like a mobile applicat... r attributes **intentionally** as Python does not deliver true privacy. Why? Guido Van Rossum, best
4.1 Shallow and deep copy operations
51 Resultats, Darrera modificació:
= 4.1 Shallow and deep copy operations == Copying objects using shallow and deep operations In this module, you’ll learn how to ... id() function and the is operand; * shallow and deep copies of the objects. It’s hard to imagine wr... that allow us to cope with objects, let's talk in detail about variables and objects, and possible way
2.8 Composition vs Inheritance - two ways to the same destination
46 Resultats, Darrera modificació:
Composition vs Inheritance - two ways to the same destination So far we've been using and following t... ation between two classes: the base class and the derived class, called a subclass. The result of thi... s is always at the top (the superclass) while its descendants are located below (the subclasses). Wha... erited in this “Vehicles” structure? All classes derived from Vehicles own properties and methods res
5.1 Metaprogramming
45 Resultats, Darrera modificació:
ht have already experienced it while implementing decorators, overriding operators, or even implementi... s of code to express a solution, in turn reducing development time. But the truth is that this techni... n** newsgroup on 12/22/2002: //[metaclasses] are deeper magic than 99% of users should ever worry abo... n about why).// Don’t worry, we'll touch on the “deeper magic” in a benign way. Understanding Python
1.2 Working with class and instance data – instance variables
44 Resultats, Darrera modificació:
in the code presented below. <code python> class Demo: def __init__(self, value): self.instance_var = value d1 = Demo(100) d2 = Demo(200) print("d1's instance variable is equal to:", d1.instance_var) print("d2's inst
2.9 Inheriting properties from built-in classes
36 Resultats, Darrera modificació:
methods. Later, you can override the methods by delivering your own modifications for the selected m... > class IntegerList(list): @staticmethod def check_value_type(value): if type(value) ... raise ValueError('Not an integer type') def __setitem__(self, index, value): Integer... list.__setitem__(self, index, value) def append(self, value): IntegerList.check_v
3.1 Advanced techniques of creating and serving exceptions
35 Resultats, Darrera modificació:
and that is why it is so important to know how to deal with exceptions. Python comes with 63((This nu... : you have to subclass BaseException or any other derived exception class. == Exception handling When... ons - named attributes Now it’s time to dive more deeply into the interesting features of exception co... ption – raised when a Unicode-related encoding or decoding error occurs. It is a subclass of ValueErro
2.5 Different faces of Python methods
30 Resultats, Darrera modificació:
have previously existed. The code in the editor demonstrates the idea presented above. <code python> class Example: def __init__(self, value): self.__internal = value def get_internal(self): return self.__intern... n> class Example: __internal_counter = 0 def __init__(self, value): Example.__interna
2.1 Python core syntax
29 Resultats, Darrera modificació:
ch instance of the class owns a set of attributes describing a person: age, salary, weight, etc. What ... to add two objects of the Person class? Well, it depends on the domain of your application. If you’re developing an application for an elevator, then you ... the core syntax are translated into magic methods delivered by specific classes. So Python knows what
1.1 Classes, Instances, Attributes, Methods — introduction
25 Resultats, Darrera modificació:
object-oriented approach is an evolution of good design practices that go back to the very beginning ... of common terms, we should agree on the following definitions: * class — an idea, blueprint, or rec... ect is a very useful culmination of all the terms described above: * it is an independent instance ... his and the next module: * creation and use of decorators; * implementation of core syntax; * c
2.3 Extended function argument syntax
24 Resultats, Darrera modificació:
arguments in an imposed order to follow function definition; * functions might have already defined default values for some parameters, so we do not have to pass all arguments as missing arguments, complete with defaults; parameters with default values are present
4.2 Serialization of Python objects using the pickle module
21 Resultats, Darrera modificació:
Python script. This reverse process is called **deserialization**. Python objects can also be seria... eferences to functions and classes, but not their definitions. Let's pickle our first set of data con... * we consecutively read some portions of data and deserialize it with the ''load()'' function; * fin... order in which the objects were persisted and the deserialization code should follow the same order.
4.3 Making Python objects persistent using the shelve module
5 Resultats, Darrera modificació: