Cerca

Heus ací els resultats de la cerca.

2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
45 Resultats, Darrera modificació:
= 2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP Inheritance is one of the fundamental concepts of object oriented programming, and expresses the fundamental relationships between classes: superclasses (parents) and their subclasses (descendants). Inheritance creat... class hierarchy inherits all the traits (methods and attributes) defined inside any of the superclasse
2.4 Decorators
38 Resultats, Darrera modificació:
s. Python is able to decorate functions, methods, and classes. The decorator's operation is based on w... can take the parameters of the decorated function and perform additional actions and that make it a real decorating function. The same principle is applied... Decorators are used to perform operations before and after a call to a wrapped object or even to preve
2.5 Different faces of Python methods
38 Resultats, Darrera modificació:
performed operations on the instances (objects), and in particular the attributes of the instance, so ... , which is their hallmark. It’s worth emphasizing and remembering that ''self'' allows you to refer to ... copy of the instance variable ''%%__internal%%'', and the ''get_internal()'' method allows you to read ... of the parameter ''self'' was chosen arbitrarily and you can use a different word, but you must do it
2.1 Python core syntax
37 Resultats, Darrera modificació:
allow us to operate on strings, lists, integers, and floats. It’s natural for us to formulate expressi... rings’ concatenation; we are able to add integers and we know what the result should be, all done by us... vers: * operators like '+', '-', '*', '/', '%' and many others; * operators like '==', '<', '>', '<=', 'in' and many others; * indexing, slicing, subscripting;
2.8 Composition vs Inheritance - two ways to the same destination
31 Resultats, Darrera modificació:
to the same destination So far we've been using and following the inheritance concept when modeling o... ight relation between two classes: the base class and the derived class, called a subclass. The result... 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 inherit
1.1 Classes, Instances, Attributes, Methods — introduction
30 Resultats, Darrera modificació:
roblems in an efficient, comfortable, extendable, and well-structured manner. Imagine that the text yo... g was rendered in a web browser created with OOP, and even the mouse cursor image is displayed using an... (treat a spreadsheet as a collection of objects), and many, many other applications. This chapter assu... ct'; * object — Python's representation of data and methods; objects could be aggregates of instances
2.9 Inheriting properties from built-in classes
29 Resultats, Darrera modificació:
alities inherited from its parent or even parents and you can still access those attributes and methods. Later, you can override the methods by delivering ... s will be based on the Python list implementation and will also validate the type of elements that are ... pecific type (integers in the ticketing example), and control over the types of elements is given to th
3.1 Advanced techniques of creating and serving exceptions
27 Resultats, Darrera modificació:
= 3.1 Advanced techniques of creating and serving exceptions In this module, we'll talk about Python ex... short introduction When Python executes a script and encounters a situation that it cannot cope with, ... eption expects somebody or something to notice it and take care of it; * if nothing happens to take c... ion, the program will be **forcibly terminated**, and you will see an error message sent to the console
4.2 Serialization of Python objects using the pickle module
25 Resultats, Darrera modificació:
n of food. The resulting food is called a pickle, and to prevent ambiguity, prefaced with the 'pickled'... persist outcomes is to generate a flat text file and to write your outcomes. It’s a very simple thing ... lso be serialized using a module called 'pickle', and using this module, you can 'pickle' your Python o... later use. The 'pickle' module is a very popular and convinient module for data serialization in the w
4.1 Shallow and deep copy operations
24 Resultats, Darrera modificació:
= 4.1 Shallow and deep copy operations == Copying objects using shallow and deep operations In this module, you’ll learn how ... bel vs. identity vs. value; * the id() function and the is operand; * shallow and deep copies of the objects. It’s hard to imagine writing a piece of P
2.6 Abstract classes
23 Resultats, Darrera modificació:
, a kind of contract between a __class designer__ and a __programmer__: * the class designer sets re... programmer has to deliver all method definitions and the completeness would be validated by another, d... n abstract class representing a base music format and corresponding methods for “open”, “play”, “get de... isn’t possible to instantiate an abstract class, and it needs subclasses to provide implementations fo
5.1 Metaprogramming
23 Resultats, Darrera modificació:
om a science fiction story, but the idea was born and implemented in the early 1960s. For Python, code... ions can occure while the code is being executed, and you might have already experienced it while imple... eed them know with certainty that they need them, and don't need an explanation about why).// Don’t wo... . In Python's approach, everything is an object, and every object has some type associated with it. To
2.3 Extended function argument syntax
19 Resultats, Darrera modificació:
cept any arbitrary number of positional arguments and keyword arguments. So far we've been using a few... ations of the **print()** function end correctly, and the argument values are passed to the standard ou... ions that accept arbitrary numbers of parameters, and you can spot them easily when reading third-party... it may look strange at first glance: //%%*%%args and %%**%%kwargs//. Don't worry, we'll tame them in a
2.7 Encapsulation
17 Resultats, Darrera modificació:
d programming (amongst inheritance, polymorphism, and abstraction). It describes the idea of bundling attributes and methods that work on those attributes within a cl... e 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 wa
1.2 Working with class and instance data – instance variables
14 Resultats, Darrera modificació:
= 1.2 Working with class and instance data – instance variables == Instance variables This kind of variable exists when and only when it is explicitly created and added to an object. This can be done during the object's initia... et's look at how the instance variable is created and accessed in the code presented below. <code pyth
4.3 Making Python objects persistent using the shelve module
10 Resultats, Darrera modificació: