Cerca

Heus ací els resultats de la cerca.

5.1 Metaprogramming
257 Resultats, Darrera modificació:
= 5.1 Metaprogramming == Introduction to metaclasses Metaprogramming is a programming technique in whi... Another example of metaprogramming is the **metaclass** concept, which is one of the most advanced co... en of Python**, expressed his feelings about metaclasses in the **comp.lang.python** newsgroup on 12/22/2002: //[metaclasses] are deeper magic than 99% o
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
153 Resultats, Darrera modificació:
nheritance and polymorphism — Inheritance as a pillar of OOP Inheritance is one of the fundamental con... nted programming, and expresses the fundamental relationships between classes: superclasses (parents) and their subclasses (descendants). Inheritance creates a class hierarchy
1.2 Working with class and instance data – instance variables
113 Resultats, Darrera modificació:
= 1.2 Working with class and instance data – instance variables == Instance variables This kind of var... tialization, performed by the __init__ method, or later at any moment of the object's life. Furthermor... are closely connected to the objects (which are class instances), not to the classes themselves. To get access to the instance variable, you should addre
2.6 Abstract classes
106 Resultats, Darrera modificació:
= 2.6 Abstract classes Python is considered to be a very flexible programming language, but that doesn’t mean that there are no co... impose a set of functionalities or an order in a class hierarchy. When you develop a system in a group... have some means of establishing requirements for classes in matters of interfaces (methods) exposed by
2.4 Decorators
92 Resultats, Darrera modificació:
design patterns that describes the structure of related objects. Python is able to decorate functions, methods, and classes. The decorator's operation is based on wrapp... al function with a new "decorating" function (or class), hence the name "decoration". This is done by ... ng function returns a function that can be called later. Of course, the **decorating** function does
1.1 Classes, Instances, Attributes, Methods — introduction
86 Resultats, Darrera modificació:
= 1.1 Classes, Instances, Attributes, Methods — introduction == Introduction to Object-Oriented Progra... with OOP, and even the mouse cursor image is displayed using an application created with OOP. The sam... should agree on the following definitions: * class — an idea, blueprint, or recipe for an instance; * instance — an instantiation of the class; very often used interchangeably with the term
2.5 Different faces of Python methods
82 Resultats, Darrera modificació:
rations on the instances (objects), and in particular the attributes of the instance, so we’ve called ... strates the idea presented above. <code python> class Example: def __init__(self, value): ... le2.get_internal()) </code> Each of the Example class objects has its own copy of the instance variab... <code ; output> 10 99 </code> == The static and class methods Two other types of method can also be u
2.8 Composition vs Inheritance - two ways to the same destination
80 Resultats, Darrera modificació:
lowing the inheritance concept when modeling our classes to represent real-life issues. Inheritance is... object-oriented programming that models a tight relation between two classes: the base class and the derived class, called a subclass. The result of this relation is a subcl
2.7 Encapsulation
69 Resultats, Darrera modificació:
= 2.7 Encapsulation == Attribute encapsulation Encapsulation is one of the fundamental concepts in object-oriented programming (amongst inherita... d methods that work on those attributes within a class. Encapsulation is used to hide the **attribute
2.1 Python core syntax
53 Resultats, Darrera modificació:
integers, and floats. It’s natural for us to formulate expressions using algebraic symbols representin... different** data types, when operations are formulated using **the same** operators or instructions, ... str(), len() * reflexion – isinstance(), issubclass() and a few more elements. Python allows us t... agine the following situation: you've created a class that represents a person; each instance of the
2.9 Inheriting properties from built-in classes
52 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, your n
4.1 Shallow and deep copy operations
37 Resultats, Darrera modificació:
s. Specifically, you'll learn about: * object: label vs. identity vs. value; * the id() function ... ys of copying them. When you spot the following clause: <code python> a_list = [ 1, 'New York', 100] ... ing used, so evaluation of the right side of the clause takes precedence over the left side.) * At ... ject has its identity; * then the object is populated with other objects. Now our object has a value
3.1 Advanced techniques of creating and serving exceptions
35 Resultats, Darrera modificació:
the normal flow of the program's instructions. Plan for the module: * short introduction to excep... Error: list index out of range </code> Sooner or later, every Pythonista will write a code that raise... d from BaseException, the most general exception class. And this approach tells you that you can also create your own specific exception classes – the only constraint is: you have to subclas
4.2 Serialization of Python objects using the pickle module
32 Resultats, Darrera modificació:
you will learn how to persist Python objects for later use. **Pickling** is the process of preservin... red saving the output of your data processing for later use? The simplest way to persist outcomes is to generate a flat text file and to write your outcomes. It’s a ver... module, you can 'pickle' your Python objects for later use. The 'pickle' module is a very popular an
2.3 Extended function argument syntax
17 Resultats, Darrera modificació:
, 23, 2) print(a_list) print(b_list) </code> Similarly to the **print()** function, the **list()** fu... answer is yes, but it may look strange at first glance: //%%*%%args and %%**%%kwargs//. Don't worry, ... amed *args and %%**%%kwargs) should be put as the last two parameters in a function definition. Their ... for handling any number of additional arguments (placed next after the expected arguments) passed to a
4.3 Making Python objects persistent using the shelve module
7 Resultats, Darrera modificació: