Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 4.1 Shallow and deep copy operations @info:cursos:pue:python-pcpp1:m1
- 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 @info:cursos:pue:python-pcpp1:m1
- ort introduction to exceptions; * review of the named attributes of exception objects; * introductio... t all potential exceptions have their unambiguous names, so you can categorize them and react appropriat... a try... except block. == Advanced exceptions - named attributes Now it’s time to dive more deeply int... clause may specify a variable after the exception name. In this example it’s an ''e_variable''. This var
- 3.1 PEP 8 – Introduction @info:cursos:pue:python-pcpp1:m2
- * **pycodestyle** (formerly called pep8, but the name was changed to avoid confusion) - Python style gu... st_one = [1, 2, 3, 4, 5, 6 ] a = my_function_name(a, b, c, d, e, f) </code> <code python ✔> #... 1, 2, 3, 4, 5, 6, ] a = my_function_name(a, b, c, d, e, f) </code> ... ituations where your comments or docstrings use a name (e.g., an author’s name) that contains a non-ASCI
- 1.1 SQLite @info:cursos:pue:python-pcpp1:m5
- example above, the method takes only the database name as the argument. This means that the database wil... .db')</code> It's also possible to use a special name, '':memory:'', which creates a database in RAM: <... onsist of only one table called tasks: * id * name * priority To create the above table, we’ll nee... tax looks like this: <code sql>CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 dat
- 1.7 Four magic letters: CRUD @info:cursos:pue:python-pcpp1:m4
- in the collection must have the property of this name – this is how the server identifies each item and... r'' assumes that the data collection inherits its name from the source data file name. As we named the file cars, the server will publish the data as cars, too. You have to use the name in
- 2.1 PEP 20 – The Zen of Python @info:cursos:pue:python-pcpp1:m2
- ty. Giving self-explanatory variable and function names, or adding more explicitness to imports or funct... e it saving time by having to think up meaningful names, the effort taken to format your code, or any ot... rs to develop in the future. Giving **meaningful names** to variables, functions, modules, and classes;... r guessing. Give your variables **self-commenting names**, and **leave comments** where necessary. If yo
- 5.1 Metaprogramming @info:cursos:pue:python-pcpp1:m1
- ent way than decorators: * decorators bind the names of decorated functions or classes to new callabl... familiar with some special attributes: * ''%%__name__%%'' – inherent for classes; contains the name of the class; * ''%%__class__%%'' – inherent for both... s dog = Dog() print('"dog" is an object of class named:', Dog.__name__) print() print('class "Dog" is a
- 4.1 Logging in Python @info:cursos:pue:python-pcpp1:m5
- ll the ''getLogger'' function without providing a name. The root logger is at the highest point in the h... s place in the hierarchy is assigned based on the names passed to the ''getLogger'' function. <code pyt... .world') recommended_logger = logging.getLogger(__name__) </code> Logger names are similar to the names of the Python modules in which the dot separator is u
- 1.4 Talking to JSON in Python @info:cursos:pue:python-pcpp1:m4
- need to. Why? Because there’s a Python module – named **JSON** – which is able to perform all those dr... rry out such an operation, you may use a function named ''dumps()''. Note: the ''’s'' at the end of the function's name means string. There is a very similar function with the name deprived of this suffix which **writes the JSON s
- 3.1 The CSV module in Python @info:cursos:pue:python-pcpp1:m5
- '' that stores contacts from a phone: <code csv> Name,Phone mother,222-555-101 father,222-555-102 wife,... above file, there are four contacts consisting of name and phone number. Note that the first line contai... It should produce the following output: <code> ['Name', 'Phone'] ['mother', '222-555-101'] ['father', '... </code> What happened? We've passed an open file named ''contacts.csv'' and a separator used to separat
- 1.2 How to use sockets in Python @info:cursos:pue:python-pcpp1:m4
- 't be surprised if we tell you that the module is named socket, will you? This is what we'll put at the... ode> === Obtaining user input We also need **the name of the HTTP server** we're going to connect to. I... two different forms: * it can be **the domain name of the server** (like //www.pythoninstitute.org /... our courses. The socket module provides a class named ''socket'' (what a coincidence!) which encapsula
- 1.5 What is XML and why do we prefer to use JSON? @info:cursos:pue:python-pcpp1:m4
- > The first (header) line contains two attribute names: ''version'' and ''encoding''. We don’t think yo... story short, the DOCTYPE line contains: * the **name** of the XML document being defined (cars_for_sal... ormal Public Identifier – a string which uniquely names the DTD on the scale of the universe) and its lo... ded about it is its URI (which may be just a file name recognizable by the target server); * the **URI
- 2.4 Decorators @info:cursos:pue:python-pcpp1:m1
- 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... ans that: * operations are performed on object names; * **this is the most important thing to remem
- 1.2 Let TkInter speak! @info:cursos:pue:python-pcpp1:m3
- from Python's point of view TkInter is a package named **tkinter**. The package contains a bunch of fun... uch an import will force you to use the qualified names of tkinter’s components. If you don’t like to write long package names each time you make use of their contents, you can perform an import which **renames** the package (precisely: which creates an **ali
- 5.1 The configparser module @info:cursos:pue:python-pcpp1:m5
- s. It consists of sections that are identified by names enclosed in square brackets. The sections contai... host = localhost # This is a comment. [mariadb] name = hello user = user password = password [redis] ... t to the MariaDB database. These are the database name, username, and password. The last section contains ''Redis'' configuration data, consisting of the por