Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 3.1 PEP 8 – Introduction @info:cursos:pue:python-pcpp1:m2
- 8 is a document that provides coding conventions (code style guide) for Python code. PEP 8 is considered one of the most important PEPs and a must-read for e... sional Python programmer, as it helps to make the code more consistent, more readable, and more efficien... about one simple but important observation:** our code will be read much more often than it will be writ
- 1.7 Four magic letters: CRUD @info:cursos:pue:python-pcpp1:m4
- your cars.json is located and launch the server: <code bash>json-server --watch cars.json</code> **Note (very important)** – the fact that the ''json-server'' serves the data initially encoded as JSON has absolutely nothing to do with the fa... ll transmit JSON messages between the client (our code) and the server (''json-server''). The way the se
- 4.1 PEP 257 – Docstring Conventions @info:cursos:pue:python-pcpp1:m2
- regulations!) associated with documenting Python code using docstrings. In short, it tries to answer th... tion about the functionality of a larger piece of code in a **prescriptive** way. They help programmers... urpose, operation, and capabilities of particular code blocks or sections. == Docstring vs. comments Bef... ggest): comments are used for **commenting** your code, while docstrings are used for **documenting** yo
- 1.1 SQLite @info:cursos:pue:python-pcpp1:m5
- lite3 module, you must import it in your script: <code python>import sqlite3</code> NOTE: The sqlite3 module has been available in Python since version 2.5. ... ect'' method provided by the ''sqlite3'' module: <code python>import sqlite3 conn = sqlite3.connect('hello.db')</code> The ''connect'' method returns the database rep
- 1.4 Talking to JSON in Python @info:cursos:pue:python-pcpp1:m4
- and we're sure that you knew it before we asked: <code python> import json </code> The first JSON module's power is the ability to automatically **convert Py... utputs a number – we don't expect anything more: <code python> import json electron = 1.602176620898E10−19 print(json.dumps(electron)) </code> The code outputs: <code ; output> 16021766189.98
- 3.1 Advanced techniques of creating and serving exceptions @info:cursos:pue:python-pcpp1:m1
- raised) when it has no idea what do to with your code. What happens next? * the raised exception ex... t an exception error message like the following: <code ; output> IndexError: list index out of range </code> Sooner or later, every Pythonista will write a code that raises an exception, and that is why it is s
- 2.4 Decorators @info:cursos:pue:python-pcpp1:m1
- message logging; * thread synchronization; * code refactorization; * caching. == Function decora... could think of. We'll decorate it in a moment. <code python> def simple_hello(): print("Hello from simple function!") </code> <code python> def simple_decorator(function): print('We are about to call "{}"'.format(function._
- 2.1 PEP 20 – The Zen of Python @info:cursos:pue:python-pcpp1:m2
- e editor window, type in ''import this'', run the code, and voilà! Can you see what happens? What you s... e encouraged to accept them and implement in your code. These, of course, should be looked upon holisti... 7.png }} == Explicit is better than implicit The code you write should be **explicit and readable**. W... onality. If not, think about leaving a comment in code to explain what’s going on so that other programm
- 2.1 File processing - XML files @info:cursos:pue:python-pcpp1:m5
- n XML tag must have a corresponding closing tag. <code xml><?xml version="1.0"?> <data> <book title=... r> <year>1603</year> </book> </data></code> == XML parsing (part 1) Processing XML files in ... ocument, pass it to the parse method as follows: <code python>import xml.etree.ElementTree as ET tree = ET.parse('books.xml') root = tree.getroot() </code> The ''getroot'' method returns the root element
- 4.1 Shallow and deep copy operations @info:cursos:pue:python-pcpp1:m1
- . It’s hard to imagine writing a piece of Python code that performs any kind of data processing without... pying them. When you spot the following clause: <code python> a_list = [ 1, 'New York', 100] </code> {{ :info:cursos:pue:python-pcpp1:pasted:20231026-143815... treat it as an absolute memory address. Run the code presented in the right pane to see how the string
- 1.6 Making life easier with the requests module @info:cursos:pue:python-pcpp1:m4
- ipt run-time environment that executes JavaScript code outside of a browser//. Don't be afraid – we’re g... in, but we aren't going to force you to write any code in it. It’ll act as a **black box** for us, and w... overed, so when you issue the following command: <code bash>npm</code> (which is short for node.js package manager) you should see a short help screen simila
- 5.1 Metaprogramming @info:cursos:pue:python-pcpp1:m1
- he ability to modify their own or other programs’ codes. It may sound like an idea from a science fictio... and implemented in the early 1960s. For Python, code modifications can occure while the code is being executed, and you might have already experienced it wh... ws programmers to minimize the number of lines of code to express a solution, in turn reducing developme
- 4.2 Serialization of Python objects using the pickle module @info:cursos:pue:python-pcpp1:m1
- 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_dict = dict() a_dict['EUR'] = {'code':'Euro', 'symbol': '€'} a_dict['GBP'] = {'code':'
- DevOps Sesión 15 (2022-03-30) ELK @info:cursos:pue:devops2022
- rial Curso ELK/1-Laboratorios ELK.pdf pag 37 * <code bash>rpm -ivh /root/packetbeat-7.0.0-x86_64.rpm</code> * <code yaml ; /etc/packetbeat/packetbeat.yml> 14 packetbeat.interfaces.device: any # packetbeat dev... abled: true 230 xpack.monitoring.elasticsearch: </code> * <code bash>packetbeat devices packetbeat tes
- 2.4 Shaping the main window and conversing with the user @info:cursos:pue:python-pcpp1:m3
- would use a method named ''title()''. Our sample code shows a window which changes its title each time ... it ten times, after which the title remains 0. <code python> import tkinter as tk def click(*args): ... ow.bind("<Button-1>", click) window.mainloop() </code> Changing the main window’s icon is more trouble... agree it’s not very elegant. Take a look at the code we've provided in the editor. <code python> impo