Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 5.1 Metaprogramming @info:cursos:pue:python-pcpp1:m1
- = 5.1 Metaprogramming == Introduction to metaclasses Metaprogramming is a programming technique in whic... Another example of metaprogramming is the **metaclass** concept, which is one of the most advanced con... en of Python**, expressed his feelings about metaclasses in the **comp.lang.python** newsgroup on 12/22/2002: //[metaclasses] are deeper magic than 99% of users should eve
- 2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP @info:cursos:pue:python-pcpp1:m1
- expresses the fundamental relationships between classes: superclasses (parents) and their subclasses (descendants). Inheritance creates a class hierarchy. Any object bound to a specific level of class
- 1.2 Working with class and instance data – instance variables @info:cursos:pue:python-pcpp1:m1
- = 1.2 Working with class and instance data – instance variables == Instance variables This kind of vari... are closely connected to the objects (which are class instances), not to the classes themselves. To get access to the instance variable, you should address... ssed in the code presented below. <code python> class Demo: def __init__(self, value): sel
- 2.6 Abstract classes @info:cursos:pue:python-pcpp1:m1
- = 2.6 Abstract classes Python is considered to be a very flexible programming language, but that doesn’... 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 each class. == What is an abstract class? An **abstract cla
- 2.5 Different faces of Python methods @info:cursos:pue:python-pcpp1:m1
- 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 variabl... <code ; output> 10 99 </code> == The static and class methods Two other types of method can also be used in the Object Oriented Approach (OOP): * class methods; * static methods. These alternative
- 1.1 Classes, Instances, Attributes, Methods — introduction @info:cursos:pue:python-pcpp1:m1
- = 1.1 Classes, Instances, Attributes, Methods — introduction == Introduction to Object-Oriented Program... 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 '... ates of instances; * attribute — any object or class trait; could be a variable or method; * method
- 2.4 Decorators @info:cursos:pue:python-pcpp1:m1
- thon is able to decorate functions, methods, and classes. The decorator's operation is based on wrappi... al function with a new "decorating" function (or class), hence the name "decoration". This is done by p... The same principle is applied when we decorate classes. We'll talk about this a bit later. So from n... m 'decorator' will be understood as a decorating class or a decorating function. Decorators are used t
- 2.8 Composition vs Inheritance - two ways to the same destination @info:cursos:pue:python-pcpp1:m1
- lowing the inheritance concept when modeling our classes to represent real-life issues. Inheritance is ... ramming 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 subclass class that inher
- 2.9 Inheriting properties from built-in classes @info:cursos:pue:python-pcpp1:m1
- = 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 new
- 2.1 Python core syntax @info:cursos:pue:python-pcpp1:m1
- str(), len() * reflexion – isinstance(), issubclass() and a few more elements. Python allows us to... agine the following situation: you've created a class that represents a person; each instance of the class owns a set of attributes describing a person: ag... at does it mean to add two objects of the Person class? Well, it depends on the domain of your applicat
- 3.1 PEP 8 – Introduction @info:cursos:pue:python-pcpp1:m2
- style guidelines. The online tool is built using Flask, Twitter Bootstrap, and the PEP8 module (the ver... blank lines** to surround top-level function and class definitions: <code python ✔> class ClassOne: pass Class ClassTwo: pass def my_top_level_function(): return None </code>
- 1.4 Talking to JSON in Python @info:cursos:pue:python-pcpp1:m4
- The trap is here: <code python> import json class Who: def __init__(self, name, age): ... ting: <code ; output> TypeError: Object of type 'Class' is not JSON serializable </code> Yes, that's t... but we expect more. <code python> import json class Who: def __init__(self, name, age): ... w.__dict__ else: raise TypeError(w.__class__.__name__ + ' is not JSON serializable') some
- 2.7 Encapsulation @info:cursos:pue:python-pcpp1:m1
- d 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 p... licly accessible **methods** are provided in the class **to access** the values, and other objects call... e attributes; * in Python, you can change your class implementation from a class that allows simple a
- 3.1 Advanced techniques of creating and serving exceptions @info:cursos:pue:python-pcpp1:m1
- 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 subclass BaseException or any other derived exception class. == Exception handling When you suspect that the
- 4.2 Serialization of Python objects using the pickle module @info:cursos:pue:python-pcpp1:m1
- o avoid cycles!) * references to functions and classes, but not their definitions. Let's pickle our ... should follow the same order. <code ; output> <class 'dict'> {'EUR': {'code': 'Euro', 'symbol': '€'},... 'JPY': {'code': 'Japanese yen', 'symbol': '¥'}} <class 'list'> ['a', 123, [10, 100, 1000]] </code> A... ntermediate object type, used to preserve data: <class 'bytes'> A type of deserialized object: <class '