name

Cerca

Heus ací els resultats de la cerca.

4.1 Shallow and deep copy operations
51 Resultats, Darrera modificació:
a variable, which you should treat as a label or name binding, is created, and this label refers to a d... <code python> import copy a_dict = { 'first name': 'James', 'last name': 'Bond', 'movies': ['Goldfinger (1964)', 'You Only Live Twice'] } b_... output** <code ; output> Source list of candies {'name': 'Lolly Pop', 'price': 0.4, 'weight': 133} {'nam
3.1 Advanced techniques of creating and serving exceptions
45 Resultats, Darrera modificació:
clause may specify a variable after the exception name. In this example it’s an ''e_variable''. This var... trying to load a module. The attributes are: * name – represents the name of the module that was attempted to be imported; * path – represents the path t... t ImportError as e: print(e.args) print(e.name) print(e.path) </code> <code ; output> ("No m
5.1 Metaprogramming
25 Resultats, Darrera modificació:
familiar with some special attributes: * ''%%__name__%%'' – inherent for classes; contains the name of the class; * ''%%__class__%%'' – inherent for both... print('"dog" is an object of class named:', Dog.__name__) print() print('class "Dog" is an instance of:'... ype(, , )'': * the argument specifies the class name; this value becomes the ''%%__name__%%'' attribut
2.4 Decorators
21 Resultats, Darrera modificació:
a new "decorating" function (or class), hence the name "decoration". This is done by passing the origina... int('We are about to call "{}"'.format(function.__name__)) return function </code> The last lines a... accepts an object as a parameter, displays a ''__name__'' attribute value of the parameter, and returns... is is the most important thing to remember**: the name of the simple_function object ceases to indicate
2.7 Encapsulation
11 Resultats, Darrera modificació:
to read the encapsulated attribute value; * the name of the designated method will be used as the name of the instance attribute corresponding to the encaps... that the method following the decorator gives the name (tank) to the attribute visible outside of the cl... e the encapsulated attribute. As those attribute name repetitions could be misleading, let's explain th
1.2 Working with class and instance data – instance variables
4 Resultats, Darrera modificació:
variable in the following way: objectdotvariable_name. Let's look at how the instance variable is crea... class variable, simply access it using the class name, and then provide the variable name. <code python> class Demo: class_var = 'shared variable' prin... creating an instance variable that holds the same name as the class variable. The following snippet show
2.2 Inheritance and polymorphism — Inheritance as a pillar of OOP
4 Resultats, Darrera modificació:
problem, or even the deadly diamond of death. The name reflects the shape of the inheritance diagram — t... t lead to printing, but naming them with a common name creates a convenient abstract interface independe... , many of them carrying the same names. The first name common to both lists is %%__add__%%, which is a s... ect was turned on </code> Duck typing is a fancy name for the term describing an application of the duc
4.3 Making Python objects persistent using the shelve module
4 Resultats, Darrera modificació:
s). <code python> new_shelve = shelve.open(shelve_name) print(new_shelve['USD']) new_shelve.close() </co... e right pane. <code python> import shelve shelve_name = 'first_shelve.shlv' my_shelve = shelve.open(shelve_name, flag='c') my_shelve['EUR'] = {'code':'Euro', 'sy... y_shelve.close() new_shelve = shelve.open(shelve_name) print(new_shelve['USD']) new_shelve.close() </c
2.5 Different faces of Python methods
2 Resultats, Darrera modificació:
. This is possible thanks to using ''self''. The name of the parameter ''self'' was chosen arbitrarily ... chosen arbitrarily (i.e., you can use a different name, but you must do it consistently). You can find
2.6 Abstract classes
2 Resultats, Darrera modificació:
ining Abstract Base Classes (ABC) and that module name is **abc**. The ABC allows you to mark classes a... uld cause some confusion – why does such a common name as “abc” conflict with my simple module “abc”? R
4.2 Serialization of Python objects using the pickle module
2 Resultats, Darrera modificació:
h built-in and user-defined) are pickled by their name reference, not by any value. This means that only the function name is pickled; neither the function’s code, nor any
1.1 Classes, Instances, Attributes, Methods — introduction
1 Resultats, Darrera modificació:
cribing the type/kind of any object; * it’s the name of a very handy Python function that returns the
2.1 Python core syntax
1 Resultats, Darrera modificació:
ted by design to handle specific operations. The name of each magic method is surrounded by double unde
2.3 Extended function argument syntax
1 Resultats, Darrera modificació:
uld be changed because it is just a convention to name them 'args' and 'kwargs', but it’s more important
2.8 Composition vs Inheritance - two ways to the same destination
1 Resultats, Darrera modificació:
ecific method, the inherited method with the same name will be called. Additionally, in the case of inhe
2.9 Inheriting properties from built-in classes
1 Resultats, Darrera modificació: