Cerca
Heus ací els resultats de la cerca.
Resultats de text complet:
- 3.1 PEP 8 – Introduction @info:cursos:pue:python-pcpp1:m2
- 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 every profe... onal Python programmer, as it helps to make the code more consistent, more readable, and more efficien
- 4.1 PEP 257 – Docstring Conventions @info:cursos:pue:python-pcpp1:m2
- ment created as part of the Python Developer's Guide, which makes an attempt to standardize the high-l... egulations!) associated with documenting Python code using docstrings. In short, it tries to answer th... function, and method definition in order to provide information about the functionality of a larger piece of code in a **prescriptive** way. They help programmers
- 1.7 Four magic letters: CRUD @info:cursos:pue:python-pcpp1:m4
- P method. == U means Update You update data inside a collection when you modify the contents of the ... ur cars.json is located and launch the server: <code bash>json-server --watch cars.json</code> **Note (very important)** – the fact that the ''json-serve... transmit JSON messages between the client (our code) and the server (''json-server''). The way the se
- 1.1 SQLite @info:cursos:pue:python-pcpp1:m5
- tems on the market. The most popular of them include: * Free: MySQL, PostgreSQL, SQLite * Paid: Or... hat have the same necessary equipment, but were made by other manufacturers. It's exactly the same wit... te3 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.
- 2.1 PEP 20 – The Zen of Python @info:cursos:pue:python-pcpp1:m2
- editor window, type in ''import this'', run the code, and voilà! Can you see what happens? What you s... encouraged to accept them and implement in your code. These, of course, should be looked upon holisti... png }} == Explicit is better than implicit The code you write should be **explicit and readable**. W... ality. If not, think about leaving a comment in code to explain what’s going on so that other programm
- 2.4 Decorators @info:cursos:pue:python-pcpp1:m1
- essage logging; * thread synchronization; * code refactorization; * caching. == Function decora... ould 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
- 3.1 Advanced techniques of creating and serving exceptions @info:cursos:pue:python-pcpp1:m1
- aised) when it has no idea what do to with your code. What happens next? * the raised exception ex... 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.1 File processing - XML files @info:cursos:pue:python-pcpp1:m5
- it's parsed into a tree structure in which each node is an object. * **xml.sax** – SAX is an acronym... st of opening and closing tags. The elements include text, attributes, and other child elements. In th... XML tag must have a corresponding closing tag. <code xml><?xml version="1.0"?> <data> <book title="The Little Prince"> <author>Antoine de Saint-Exupéry</author> <year>1943</year>
- 1.4 Talking to JSON in Python @info:cursos:pue:python-pcpp1:m4
- d 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 ... puts 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
- 1.6 Making life easier with the requests module @info:cursos:pue:python-pcpp1:m4
- ed ''json-server'', implemented on top of the ''Node.js'' environment. ''Node.js'' is – as Wikipedia claims – //an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser//. Don't be afraid – we’re going to encounter JavaScript again, but we aren't go
- 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... ing them. When you spot the following clause: <code python> a_list = [ 1, 'New York', 100] </code> {{ :info:cursos:pue:python-pcpp1:pasted:20231026-1438... ement is being used, so evaluation of the right side of the clause takes precedence over the left side
- 1.5 What is XML and why do we prefer to use JSON? @info:cursos:pue:python-pcpp1:m4
- ke a look – it's a simple sample XML document: <code xml><?xml version = "1.0" encoding = "utf-8"?> <!... <brand>Aston Martin</brand> <model>Rapide</model> <production_year>2010</production_y... "GBP">32000</price> </car> </cars_for_sale></code> The document contains a part of an offer publis... e first line – it plays a very important role: <code xml><?xml version = "1.0" encoding = "utf-8"?></c
- 5.1 Metaprogramming @info:cursos:pue:python-pcpp1:m1
- nd implemented in the early 1960s. For Python, code modifications can occure while the code is being executed, and you might have already experienced it ... programmers to minimize the number of lines of code to express a solution, in turn reducing developme... eparation; those tools could be applied to your code to make it follow specific programming patterns,
- 2.3 A small lexicon of widgets - Part 3 @info:cursos:pue:python-pcpp1:m3
- widget doesn’t take the focus itself. Run the code and test its behavior. <code python> import tkinter as tk def digits_only(*args): global last_... y.pack() entry.focus_set() window.mainloop() </code> Try to modify the code to allow the user to enter not more than five digits. The last part of our
- 4.2 Serialization of Python objects using the pickle module @info:cursos:pue:python-pcpp1:m1
- ring, 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':'