in

Cerca

Heus ací els resultats de la cerca.

2.4 Decorators
53 Resultats, Darrera modificació:
thout directly modifying it. Decorators are used in: * the validation of arguments; * the modifi... st functions we could think of. We'll decorate it in a moment. <code python> def simple_hello(): ... he whole code should look like the code presented in the right pane. When you run the code, the resul... her lines? Where is the simplicity or convenience in this approach? Well … we could say … you should
3.1 Advanced techniques of creating and serving exceptions
50 Resultats, Darrera modificació:
ced techniques of creating and serving exceptions In this module, we'll talk about Python exceptions –... ay vary across different Python versions.)) built-in exceptions, and they can be represented in the form of a tree-shaped hierarchy. The reason for this i... lock to surround the "problematic" piece of code. In effect, when the exception is raised, execution i
5.1 Metaprogramming
48 Resultats, Darrera modificació:
lasses Metaprogramming is a programming technique in which computer programs have the ability to modif... tion story, but the idea was born and implemented in the early 1960s. For Python, code modifications ... tocol. It may look like syntactic sugar, because in many cases metaprogramming allows programmers to ... he number of lines of code to express a solution, in turn reducing development time. But the truth is
4.2 Serialization of Python objects using the pickle module
41 Resultats, Darrera modificació:
ization of Python objects using the pickle module In this section, you will learn how to persist Pytho... different types of objects or nested structures. In Python, object **serialization** is the process o... ucture into a stream of bytes to store the object in a file or database, or to transmit it via a netwo... e information necessary to reconstruct the object in another Python script. This reverse process is c
2.9 Inheriting properties from built-in classes
40 Resultats, Darrera modificació:
= 2.9 Inheriting properties from built-in classes Python gives you the ability to create a class that inherits properties from any Python built-in class in order to get a new class that can enrich the parent's attributes or methods. As a result, yo... your own modifications for the selected methods. In the following example, we’ll create an implementa
4.1 Shallow and deep copy operations
40 Resultats, Darrera modificació:
Copying objects using shallow and deep operations In this module, you’ll learn how to copy Python obje... ts that allow us to cope with objects, let's talk in detail about variables and objects, and possible ... the left side.) * At first, an object (a list in this example) is created in the computer's memory. Now the object has its identity; * then the obje
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
32 Resultats, Darrera modificació:
re are no obstacles to using multiple inheritance in Python. You can derive any new class from more th... impler, safer, and easier to understand and maintain; * multiple inheritance may make method overrid... nd B, as these two variants mean different things in Python) Can you see the diamond there? {{ :info:c... D(B, C): pass D().info() # Class B </code> In the multiple inheritance scenario, any specified
2.5 Different faces of Python methods
29 Resultats, Darrera modificació:
formed operations on the instances (objects), and in particular the attributes of the instance, so we’... refer to the instance. Of course, it follows that in order to successfully use the instance method, th... instance must have previously existed. The code in the editor demonstrates the idea presented above.... a different word, but you must do it consistently in your code. It follows from the convention that //
2.1 Python core syntax
26 Resultats, Darrera modificació:
senting operators, or to get a number of elements in a sequence or dictionary. We are able to add two or more strings together, which results in the strings’ concatenation; we are able to add in... ments of a tuple, list, dictionary, or characters in a string. This is Python core syntax – an abilit... others; * operators like '==', '<', '>', '<=', 'in' and many others; * indexing, slicing, subscrip
2.7 Encapsulation
24 Resultats, Darrera modificació:
Encapsulation is one of the fundamental concepts in object-oriented programming (amongst inheritance,... tes and methods that work on those attributes within a class. Encapsulation is used to hide the **attributes** inside a class like in a **capsule**, preventing unauthorized parties' d... hem. Publicly accessible **methods** are provided in the class **to access** the values, and other obj
1.1 Classes, Instances, Attributes, Methods — introduction
23 Resultats, Darrera modificació:
ramming. This very important approach is present in most computer applications because it allows prog... programmers to model interactions between objects in order to solve real-life problems in an efficient, comfortable, extendable, and well-structured manne... ne that the text you are now reading was rendered in a web browser created with OOP, and even the mous
2.8 Composition vs Inheritance - two ways to the same destination
21 Resultats, Darrera modificació:
and potentially increase application reliability in case of changes. In case of any problems, it will also be easier to find the cause of the error. As ... below (the subclasses). What could be inherited in this “Vehicles” structure? All classes derived f... property from the base class, then it is present in all subclasses. The same principle should apply
1.2 Working with class and instance data – instance variables
20 Resultats, Darrera modificació:
variables – they don't interfere with one another in any way. The word instance suggests that they are... nstance variable, you should address the variable in the following way: objectdotvariable_name. Let's... how the instance variable is created and accessed in the code presented below. <code python> class De... ists the contents of each object, using the built-in __dict__ property that is present for every Pytho
2.3 Extended function argument syntax
19 Resultats, Darrera modificació:
s; we have to pass a required number of arguments in an imposed order to follow function definition; ... as keyword parameters; * we can pass arguments in any order if we are assigning keywords to all arg... ocation accepts an arbitrary number of arguments. In fact, there are many, many other functions that a... and %%**%%kwargs//. Don't worry, we'll tame them in a short moment. These two special identifiers (n
2.6 Abstract classes
16 Resultats, Darrera modificació:
ls to impose a set of functionalities or an order in a class hierarchy. When you develop a system in a group of programmers, it would be useful to have so... me means of establishing requirements for classes in matters of interfaces (methods) exposed by each c... ted by just declaring them, but not defining them in detail. Such methods are called **abstract method
4.3 Making Python objects persistent using the shelve module
5 Resultats, Darrera modificació: