Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 2.7 Encapsulation
- r attributes **intentionally** as Python does not deliver true privacy. Why? Guido Van Rossum, best k... attribute, and before the method responsible for deleting the encapsulated attribute. Let's have look... ssible to set negative liquid level') @level.deleter def level(self): if self.__level ... ct has a ''%%__level%%'' attribute, and the class delivers the methods responsible for handling access
- 2.6 Abstract classes
- d **abstract methods**. * The programmer has to deliver all method definitions and the completeness w... ated by another, dedicated module. The programmer delivers the method definitions by __overriding__ the... code to be polymorphic, so all subclasses have to deliver a set of their own method implementations in ... ework your music player code, you’ll just have to deliver a class supporting the new file format, fulfi
- 2.9 Inheriting properties from built-in classes
- methods. Later, you can override the methods by delivering your own modifications for the selected me... ething that’s worth commenting on is that we have delivered: * a static, dedicated method for checking argument types. As we have delegated this responsibility to only one method, the... ction of elements to the object. What have we not delivered? * All the remaining methods have remain
- 2.8 Composition vs Inheritance - two ways to the same destination
- sing and following the inheritance concept when modeling our classes to represent real-life issues. Inh... foundations of object-oriented programming that models a tight relation between two classes: the base c... asses are **tightly** coupled. **Inheritance** models what is called an **is a** relation. Examples: ... sing a concept named composition. This concept models another kind of relation between objects; it mod
- 4.1 Shallow and deep copy operations
- * is implemented by the ''deepcopy()'' function, delivered by the python 'copy' module {{ :info:cursos... lead you to the total weight details of the given delicacy. The input is presented in the editor; * P... then iterate over it to reduce the price of each delicacy by 20% if its weight exceeds the value of 30... w let's rework the code a bit: * introduce the Delicacy class to represent a generic delicacy. The o
- 2.1 Python core syntax
- the core syntax are translated into magic methods delivered by specific classes. So Python knows what ... ed to the __len__() method. These methods must be delivered by a class (now it’s clear why we treat cla... __and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq... e look somehow familiar, so let's see the details delivered by Python itself. The Python help() functi
- 2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
- g, printing, and sending via fax. The methods are delivered by the following classes: * scan(), delivered by the Scanner class; * print(), delivered by the Printer class; * send() and print(), delivered by the Fax class. Each method should print
- 4.3 Making Python objects persistent using the shelve module
- ith shelves in the pantry is a correct one. Looks delicious, doesn’t it? Using shelve is quite easy an... as when applied to a Python dictionary; * the ''del'' instruction, used to delete a key-value pair. After running the code, you'll notice additionally th
- 1.1 Classes, Instances, Attributes, Methods — introduction
- r applications because it allows programmers to model entities representing real-life objects. Moreover, OOP allows programmers to model interactions between objects in order to solve re
- 3.1 Advanced techniques of creating and serving exceptions
- eve this, we could use the ''format_tb()'' method delivered by the built-in traceback module to get a l... ck. We could use the ''print_tb()'' method, also delivered by the traceback module, to print strings d
- 1.2 Working with class and instance data – instance variables
- c devices used for calling. This class definition delivers the **call** method, which displays the obje
- 2.4 Decorators
- decorators have gained great popularity and are widely used in Python code. It should be mentioned that