Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 2.9 Inheriting properties from built-in classes
- lt, your newly-created class has the advantage of all of the well-known functionalities inherited from its parent or even parents and you can still access... object? Imagine that you need to collect the serial numbers of sold tickets. Sound reasonable enough?... based on the Python list implementation and will also validate the type of elements that are about to
- 2.1 Python core syntax
- ar we have been using Python core operations that allow us to operate on strings, lists, integers, and floats. It’s natural for us to formulate expressions using algebraic symbols representing operators, or to get a number of... d integers and we know what the result should be, all done by using the “+” operator, but on respectiv
- 2.4 Decorators
- orator's operation is based on wrapping the original function with a new "decorating" function (or cla... e "decoration". This is done by passing the original function (i.e., the **decorated** function) as a ... function so that the **decorating** function can call the passed function. The decorating function returns a function that can be called later. Of course, the **decorating** function
- 2.5 Different faces of Python methods
- ticular the attributes of the instance, so we’ve called them i**nstance methods**. The instance metho... ter, take the ''self'' parameter, which is their hallmark. It’s worth emphasizing and remembering that ''self'' allows you to refer to the instance. Of course, it f... de python> class Example: def __init__(self, value): self.__internal = value def get_
- 2.7 Encapsulation
- ncapsulation Encapsulation is one of the fundamental concepts in object-oriented programming (amongst ... ds** are provided in the class **to access** the values, and other objects call those methods to retrieve and modify the values within the object. This can be a way to enforce a ce
- 3.1 Advanced techniques of creating and serving exceptions
- ing and serving exceptions In this module, we'll talk about Python exceptions – objects that represent... the execution of a program that disrupts the normal flow of the program's instructions. Plan for the... ts; * introduction to chained exceptions; * analysis of the traceback object of each exception. =... , it: * stops your program; * creates a special kind of data, called an **exception**. Of course,
- 2.6 Abstract classes
- there are no controls to impose a set of functionalities or an order in a class hierarchy. When you d... ut not defining them in detail. Such methods are called **abstract methods**. * The programmer has to deliver all method definitions and the completeness would be validated by another, dedicated module. The programme
- 4.1 Shallow and deep copy operations
- = 4.1 Shallow and deep copy operations == Copying objects using shallow and deep operations In this module, you’ll learn how to copy Python objects. Specifically, you'll learn about: * object: label vs. identity vs. value; * the id() function and the is operand; *
- 1.2 Working with class and instance data – instance variables
- object. This can be done during the object's initialization, performed by the __init__ method, or late... <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 instance varia
- 1.1 Classes, Instances, Attributes, Methods — introduction
- present in most computer 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 real-life problems in an efficient, comfortable, exten
- 2.8 Composition vs Inheritance - two ways to the same destination
- concept when modeling our classes to represent real-life issues. Inheritance is a great concept, one ... o classes: the base class and the derived class, called a subclass. The result of this relation is a subclass class that inherits **all** methods and **all** properties of the base class, and allows a subclass to extend everything that
- 2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
- pillar of OOP Inheritance is one of the fundamental concepts of object oriented programming, and expresses the fundamental relationships between classes: superclasses (pare... d to a specific level of class hierarchy inherits all the traits (methods and attributes) defined insi... ng a new class, not from scratch, but by using an already defined repertoire of traits. The new class
- 5.1 Metaprogramming
- le the code is being executed, and you might have already experienced it while implementing decorators... ctic sugar, because in many cases metaprogramming allows programmers to minimize the number of lines o... ther you need them, you don't (the people who actually need them know with certainty that they need th... ines the behavior of certain objects, a metaclass allows for the customization of class instantiation.
- 2.3 Extended function argument syntax
- = 2.3 Extended function argument syntax When we talk about function arguments, we should recall the following facts: * some functions can be invoked w... low function definition; * functions might have already defined default values for some parameters, so we do not have to pass all arguments as missing a
- 4.2 Serialization of Python objects using the pickle module
- = 4.2 Serialization of Python objects using the pickle module In this section, you will learn how to p... ding the lifespan of food. The resulting food is called a pickle, and to prevent ambiguity, prefaced w... ts or nested structures. In Python, object **serialization** is the process of converting an object s... nsmit it via a network. This byte stream contains all the information necessary to reconstruct the obj