Cerca

Heus ací els resultats de la cerca.

2.4 Decorators
320 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
4.1 Shallow and deep copy operations
150 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 ... ally, you'll learn about: * object: label vs. identity vs. value; * the id() function and the is operand; * shallow and deep copies of the objects. It’s hard to imagine wr
2.6 Abstract classes
146 Resultats, Darrera modificació:
= 2.6 Abstract classes Python is considered to be a very flexible programming language, but that doesn... ntrols 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 hav... tract class? An **abstract class** should be considered a blueprint for other classes, a kind of contr
3.1 Advanced techniques of creating and serving exceptions
140 Resultats, Darrera modificació:
hat an exception has been raised) when it has no idea what do to with your code. What happens next? * the raised exception expects somebody or somethi... taken care of and **handled** properly, the suspended program can be resumed and its execution can continue. Python provides effective tools that allow you to **observe exce
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
126 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 that inheritance is a way of building a new class, not from scratch, but by using an already defined repertoire of traits. The new class inherits
5.1 Metaprogramming
124 Resultats, Darrera modificació:
ability to modify their own or other programs’ codes. It may sound like an idea from a science fiction story, but the idea was born and implemented in the early 1960s. For Python, code modifications can occure while the code is being
2.7 Encapsulation
91 Resultats, Darrera modificació:
t inheritance, polymorphism, and abstraction). It describes the idea of bundling attributes 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' direct acce
2.9 Inheriting properties from built-in classes
89 Resultats, Darrera modificació:
ts properties from any Python built-in class in order to get a new class that can enrich the parent's ... ose attributes and methods. Later, you can override the methods by delivering your own modifications for the selected methods. In the following example,... e problem and not on type control. Look at the code presented in the editor pane. <code python> clas
1.2 Working with class and instance data – instance variables
86 Resultats, Darrera modificació:
when and only when it is explicitly created and added to an object. This can be done during the object... nstance variable is created and accessed in the code presented below. <code python> class Demo: def __init__(self, value): self.instance_var = value d1 = Demo(100)
2.8 Composition vs Inheritance - two ways to the same destination
85 Resultats, Darrera modificació:
Composition vs Inheritance - two ways to the same destination So far we've been using and following the inheritance concept when modeling our classes to represent real-life issues. In... foundations of object-oriented programming that models a tight relation between two classes: the base class and the derived class, called a subclass. The result of thi
4.2 Serialization of Python objects using the pickle module
77 Resultats, Darrera modificació:
with the 'pickled' adjective. Have you ever considered saving the output of your data processing for ... 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... ring, an integer, and a list. When you run the code presented in the right pane, a new file should be
2.5 Different faces of Python methods
72 Resultats, Darrera modificació:
to the instance. Of course, it follows that in order to successfully use the instance method, the instance must have previously existed. The code in the editor demonstrates the idea presented above. <code python> class Example: def __init__(self, value):
2.1 Python core syntax
64 Resultats, Darrera modificació:
'==', '<', '>', '<=', 'in' and many others; * indexing, slicing, subscripting; * built-in function... 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
2.3 Extended function argument syntax
61 Resultats, Darrera modificació:
= 2.3 Extended function argument syntax When we talk about function arguments, we should recall the fo... ss a required number of arguments in an imposed order to follow function definition; * functions might have already defined default values for some parameters, so we do not ha
1.1 Classes, Instances, Attributes, Methods — introduction
59 Resultats, Darrera modificació:
object-oriented approach is an evolution of good design practices that go back to the very beginning ... 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 real-life problems in an efficient, comfortable, exte
4.3 Making Python objects persistent using the shelve module
25 Resultats, Darrera modificació: