all

Cerca

Heus ací els resultats de la cerca.

2.4 Decorators
47 Resultats, Darrera modificació:
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 ... re used to perform operations before and after a call to a wrapped object or even to prevent its execut... _decorator(function): print('We are about to call "{}"'.format(function.__name__)) return funct
2.5 Different faces of Python methods
28 Resultats, Darrera modificació:
ticular the attributes of the instance, so we’ve called them i**nstance methods**. The instance method... 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 fo... __internal%%'', and the ''get_internal()'' method allows you to read the instance variable specific to
1.1 Classes, Instances, Attributes, Methods — introduction
26 Resultats, Darrera modificació:
present in most computer applications because it allows programmers to model entities representing real-life objects. Moreover, OOP allows programmers to model interactions between obje... lf of the class or object; some say that it’s a 'callable attribute'; * type — refers to the class th... Because an object is a very useful culmination of all the terms described above: * it is an independ
2.8 Composition vs Inheritance - two ways to the same destination
26 Resultats, Darrera modificació:
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 has been inherited. By
2.6 Abstract classes
23 Resultats, Darrera modificació:
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 ... reason is: we want our code to be polymorphic, so all subclasses have to deliver a set of their own method implementations in order to call them by using common method names. Furthermore,
5.1 Metaprogramming
22 Resultats, Darrera modificació:
ctic sugar, because in many cases metaprogramming allows programmers to minimize the number of lines of... ther you need them, you don't (the people who actually need them know with certainty that they need the... ines the behavior of certain objects, a metaclass allows for the customization of class instantiation. ... e names of decorated functions or classes to new callable objects. Class decorators are applied when cl
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
21 Resultats, Darrera modificació:
d to a specific level of class hierarchy inherits all the traits (methods and attributes) defined insid... its. The new class inherits (and this is the key) all the already existing equipment, but is able to ad... ass TrackedVehicle(LandVehicle): pass</code> All the presented classes are empty for now, as we're... erited from both classes B and C. If you want to call the method info(), which part of the code would b
2.9 Inheriting properties from built-in classes
20 Resultats, Darrera modificació:
lt, your newly-created class has the advantage of all of the well-known functionalities inherited from ... ing) an element at a given position. This method calls the check_value_type() method and later calls the genuine method ''%%__setitem__%%'' which comes from... s to the object. What have we not delivered? * All the remaining methods have remained unchanged, so
4.1 Shallow and deep copy operations
18 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 copy Python objects. Specifically, you'll learn about: * object: label vs. iden... ; * the id() function and the is operand; * shallow and deep copies of the objects. It’s hard to i
2.3 Extended function argument syntax
17 Resultats, Darrera modificació:
en we talk about function arguments, we should recall the following facts: * some functions can be i... es for some parameters, so we do not have to pass all arguments as missing arguments, complete with def... ents in any order if we are assigning keywords to all argument values, otherwise positional ones are th... nt(3) print(1, 20, 10) print('--', '++') </code> All presented invocations of the **print()** function
2.7 Encapsulation
17 Resultats, Darrera modificació:
lass **to access** the values, and other objects call those methods to retrieve and modify the values w... ept has some interesting features: * the code calling the proxy methods might not realize if it is "... hange your class implementation from a class that allows simple and direct access to attributes to a cl... . You have a set of controls ( **methods** ) that allow you to manage your laundry, or even see it (man
1.2 Working with class and instance data – instance variables
15 Resultats, Darrera modificació:
t this variable is created coherently and individually for the instance to make it independent from oth... instance variable of any object has no impact on all the remaining objects. Instance variables are com... nstance. Because it is owned by the class itself, all class variables are shared by all instances of the class. They will therefore generally have the same
3.1 Advanced techniques of creating and serving exceptions
15 Resultats, Darrera modificació:
our program; * creates a special kind of data, called an **exception**. Of course, this exception is an object. Both of these activities are called **raising an exception**. We can say that Pytho... n continue. Python provides effective tools that allow you to **observe exceptions, identify them and ... iciently**. This is possible due to the fact that all potential exceptions have their unambiguous names
2.1 Python core syntax
12 Resultats, Darrera modificació:
ar we have been using Python core operations that allow us to operate on strings, lists, integers, and ... d integers and we know what the result should be, all done by using the “+” operator, but on respective... ), issubclass() and a few more elements. Python allows us to employ operators when applied to our obj... not exceed the safety limit, your elevator should allow them to be lifted. When called, functions and
4.2 Serialization of Python objects using the pickle module
11 Resultats, Darrera modificació:
ding the lifespan of food. The resulting food is called a pickle, and to prevent ambiguity, prefaced wi... nsmit it via a network. This byte stream contains all the information necessary to reconstruct the obje... another Python script. This reverse process is called **deserialization**. Python objects can also be serialized using a module called 'pickle', and using this module, you can 'pickl
4.3 Making Python objects persistent using the shelve module
7 Resultats, Darrera modificació: