Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 4.1 Shallow and deep copy operations
- . Don’t treat it as an absolute memory address. Run the code presented in the right pane to see how t... n values of the id() function must be the same. Run the code presented in the right pane to confirm o... both variables referring to the same identity?” Run the code presented in the editor. <code python> ... e object?", a_list is b_list) </code> When you run the code, you get the following output: <code ; o
- 2.7 Encapsulation
- s if they were attributes. Examine the code and run it to see if it follows your expectations. <code... : raise AccountError("No es pot modificar un número de compte!") @account.deleter... raise AccountError("No es pot esborrar un compte amb saldo diferent de 0") else: ... raise AccountError("No es pot esborrar un compte amb saldo diferent de 0") else:
- 2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
- ss class MFD_SFP(Scanner,Printer,Fax): pass oUn=MFD_SFP() oDos=MFD_SPF() oUn.scan() oUn.print() oUn.send() oDos.scan() oDos.print() oDos.send() </code> == Inheritance and polymorphism — I
- 4.2 Serialization of Python objects using the pickle module
- ning a string, an integer, and a list. When you run the code presented in the right pane, a new file should be created. Remember to run the code locally. <code python> import pickle a_... ully, and now we can retrieve it from the file. Run the code in the editor and see what happens. <co... ta.size) print(data.get_size()) </code> If you run the code, you receive: <code ; output> Traceback
- 5.1 Metaprogramming
- ny object, make use of the ''type()'' function. Run the code in the right pane to see the ''type()'' ... instance in the computer memory; this method is run before ''%%__init__%%''(); * ''%%__init__%%''... s! == Metaprogramming – another metaclass Let's run a more serious experiment: try to build a metacla... th classes rely on the same metaclass. When you run the code, you'll see that both class instances ar
- 1.1 Classes, Instances, Attributes, Methods — introduction
- a place which binds data with the code. If you run the code, there are no visible effects. The class... ttribute, issue: print(duckling.height). If you run the code, you'll get the following example: <code... class is contained in %%**__class__**%%. If you run the code presented in the right pane, you'll get
- 2.4 Decorators
- the code presented in the right pane. When you run the code, the result should be: <code ; output> W... transcribed to the code presented on the right. Run it to see the output and compare it to the output... hon> @object_counter class Car: </code> When you run the code, you can see that access to the 'mileage
- 2.1 Python core syntax
- method, __add__(), which will fix the problem. Run the code to check our prediction. <code python>c... the __abs__ and __add__ special methods. Try to run your own experiments with built-in methods. Now
- 2.6 Abstract classes
- ich is delivered by the abc module. * When you run the code, the output doesn’t surprise anyone: <c... as “abc” conflict with my simple module “abc”? Run your own experiment to become familiar with the e
- 3.1 Advanced techniques of creating and serving exceptions
- ttribute of the **RocketNotReadyError** object. Run the code in the right pane and examine the output... approach has become more generic: we are able to run two different checks, each returning a different
- 2.3 Extended function argument syntax
- inter) which could be misleading for you. Let's run the Python code presented in the right pane and s
- 2.8 Composition vs Inheritance - two ways to the same destination
- ethod) to make it work in a polymorphic manner. Run the code to confirm your expectations. <code ; o
- 2.9 Inheriting properties from built-in classes
- still calling the corresponding methods. As you run the code, you'll see that the new class is compat