Cerca

Heus ací els resultats de la cerca.

2.6 Abstract classes
13 Resultats, Darrera modificació:
ract methods**. * The programmer has to deliver all method definitions and the completeness would be ... reason is: we want our code to be polymorphic, so all subclasses have to deliver a set of their own met... loper has implemented a subclass that overrides __all__ abstract methods. When we’re designing large f... t to provide common implemented functionality for all implementations of the class, we could also use a
2.3 Extended function argument syntax
12 Resultats, Darrera modificació:
es for some parameters, so we do not have to pass all arguments as missing arguments, complete with def... ents in any order if we are assigning keywords to all argument values, otherwise positional ones are th... nt(3) print(1, 20, 10) print('--', '++') </code> All presented invocations of the **print()** function... d function: * ** *args** – refers to a tuple of all additional, not explicitly expected positional ar
2.8 Composition vs Inheritance - two ways to the same destination
12 Resultats, Darrera modificació:
this relation 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 inherited. By... could be inherited in this “Vehicles” structure? All classes derived from Vehicles own properties and
2.9 Inheriting properties from built-in classes
9 Resultats, Darrera modificació:
lt, your newly-created class has the advantage of all of the well-known functionalities inherited from ... s to the object. What have we not delivered? * All the remaining methods have remained unchanged, so... ent if you wish; note: you have to teach the code all the lengths used in Europe) * (step 2) Move the... itial characters to the number's end, and convert all letters to upper case (step 02 of the algorithm)
1.1 Classes, Instances, Attributes, Methods — introduction
8 Resultats, Darrera modificació:
present in most computer applications because it allows programmers to model entities representing real-life objects. Moreover, OOP allows programmers to model interactions between obje... Because an object is a very useful culmination of all the terms described above: * it is an independ... erstand anything that can be called; such objects allow you to use round parentheses () and eventually
2.5 Different faces of Python methods
8 Resultats, Darrera modificació:
s worth emphasizing and remembering that ''self'' allows you to refer to the instance. Of course, it fo... __internal%%'', and the ''get_internal()'' method allows you to read the instance variable specific to ... e the class method as an alternative constructor, allowing you to handle an additional argument. <code... sses, because they lack the parameters that would allow this. <code python> class Bank_Account: de
2.4 Decorators
7 Resultats, Darrera modificació:
which the decorator will be more generic – we’ll allow you to pass the packing material in the argumen... e function to make it able to handle arguments at all call levels. The ''pack_books'' function will be... unction definition. == Decorator stacking Python allows you to apply multiple decorators to a callable... expressed with functions, is: * classes bring all the subsidiarity they can offer, like inheritance
1.2 Working with class and instance data – instance variables
6 Resultats, Darrera modificació:
instance variable of any object has no impact on all the remaining objects. Instance variables are com... nstance. Because it is owned by the class itself, all class variables are shared by all instances of the class. They will therefore generally have the same ... iable' d1 = Demo() d2 = Demo() # both instances allow access to the class variable print(d1.class_var
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
6 Resultats, Darrera modificació:
d to a specific level of class hierarchy inherits all the traits (methods and attributes) defined insid... its. The new class inherits (and this is the key) all the already existing equipment, but is able to ad... ass TrackedVehicle(LandVehicle): pass</code> All the presented classes are empty for now, as we're... ferent lines being printed; * **polymorphism**: all class instances allow the calling of the turn_on(
3.1 Advanced techniques of creating and serving exceptions
6 Resultats, Darrera modificació:
n continue. Python provides effective tools that allow you to **observe exceptions, identify them and ... iciently**. This is possible due to the fact that all potential exceptions have their unambiguous names... normally should be used as a last resort to catch all unhandled exceptions. It’s so wide because we don... s a very serious process, you should be sure that all checks are passed. If any fails, it should be mar
5.1 Metaprogramming
6 Resultats, Darrera modificació:
ctic sugar, because in many cases metaprogramming allows programmers to minimize the number of lines of... ines the behavior of certain objects, a metaclass allows for the customization of class instantiation. ... classes with a method (if missing) to ensure that all your classes are equipped with a method named 'gr... etaclass that is responsible for: * equipping all newly instantiated classes with time stamps, pers
2.1 Python core syntax
5 Resultats, Darrera modificació:
ar we have been using Python core operations that allow us to operate on strings, lists, integers, and ... d integers and we know what the result should be, all done by using the “+” operator, but on respective... ), issubclass() and a few more elements. Python allows us to employ operators when applied to our obj... not exceed the safety limit, your elevator should allow them to be lifted. When called, functions and
2.7 Encapsulation
5 Resultats, Darrera modificació:
hange your class implementation from a class that allows simple and direct access to attributes to a cl... . You have a set of controls ( **methods** ) that allow you to manage your laundry, or even see it (man... nown as the author of Python, once said: "//We're all consenting adults here//" justifying the absence ... ing the liquid level to a negative value. Python allows you to control access to attributes with the b
4.1 Shallow and deep copy operations
2 Resultats, Darrera modificació:
ables. As variables are fundamental elements that allow us to cope with objects, let's talk in detail a... opy()'' method copies the whole object, including all nested objects; it’s an example of practical recu
4.2 Serialization of Python objects using the pickle module
2 Resultats, Darrera modificació:
nsmit it via a network. This byte stream contains all the information necessary to reconstruct the obje... ly the object is persisted but not its definition allowing us to determine the attribute layout: <code
4.3 Making Python objects persistent using the shelve module
1 Resultats, Darrera modificació: